Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Social Machines (Refresh Savannah, April 2013)

Social Machines (Refresh Savannah, April 2013)

Avatar for Mark Stahl

Mark Stahl

April 16, 2013
Tweet

More Decks by Mark Stahl

Other Decks in Programming

Transcript

  1. SOCIAL MACHINES A server-side programming language. Every object is a

    concurrent unit of computation, libraries can be shared like peers in a BitTorrent network, and communication between peers is encrypted. Mark Stahl Refresh Savannah, April 2013
  2. GOALS & OBSERVATIONS 1. Every object is an isolated, concurrent

    unit, easing the burden of the programmer by removing the need to choose whether to thread code. 2. All modern languages are designed for writing a single application running on a single machine. The network is an afterthought and therefore punished to APIs. This is invalid due to the ubiquity of the Internet. 3. The privacy of all communications, whether computational in nature or not, is paramount. All messages between local and remote should be encrypted.
  3. INFORMATION • Open Source (GNU AGPL v3.0, BSD) • Hosted

    at: https://github.com/mjstahl/socialmachines • Implemented in Google's Go programming language • v0.3+ is approximately ~3.8K LOC (incl. comments)
  4. IMPLEMENTATION ROADMAP Q1 2013 (COMPLETE) v0.1 - Scanner, Parser v0.2

    - Runtime v0.3 - Distribution Q2 2013 (IN PROGRESS) v0.4 - Assignment, Block Arguments, Cascades v0.5 - Integers v0.6 - Arrays, "Message Patterns" Q3 2013 v0.7 - Strings, Characters v0.8 - Hash Tables, Symbols v0.9 - Floats Q4 2013 v0.10 - Attributes (state), Byzantine Paxos
  5. SEMANTICS carl hewitt, daniel friedman, david wise, henry baker ('76,

    '77) The core of the semantics is Carl Hewitt's Actor Model. All objects exhibit three core behaviors: • Create Objects • Receive Messages • Send Messages All message sending is asynchronous except to Promises, which are ALWAYS local. Promises are first-class (passed as arguments, receive messages, send messages, etc.)
  6. SYNCHRONOUS MESSAGES 1. Send Synchronous Message (bar) No Value -

    hold onto message, blocking sender. Value - Create Promise, return it to sender, forward message to value 3. Create Promise 4. Return Promise to Sender 2. Send Asynchronous Message (value:) 5. Send Asynchronous Message (bar) 6. Send Asynchronous Message (value:) A C P P2
  7. SYNTAX (Definitions) objective-c, smalltalk, ruby + True not => {

    False } + True & aBool => { aBool ifTrue: { True } ifFalse: { False } } + True ifTrue: tBlock ifFalse: fBlock => { tBlock value }
  8. SYNTAX (Messages) >>> True not === False (0x8293 @ 192.168.33.104:10810)

    >>> True & True === True (...) >>> True ifTrue: { True not } ifFalse: { False not } === False
  9. SYNTAX (Integers) smalltalk integer* := 2 '#' [0 | 1]+

    "base 2 (binary)" | 8 '#' [0-7]+ "base 8 (octal)" | [10 '#'] [0-9]+ "base 10 (decimal)" | 16 '#' [a-f | A-F | 0-7]+ "base 16 (hexadecimal)" >>> 4 "4" >>> 2#0110 "6" >>> 8#7231 "3737" >>> 16#ff00 "65280, yellow" * sans signing. floats were not included to save the you from any more EBNF notation
  10. SYNTAX (Characters, Strings, Symbols) clojure, smalltalk, snobol Characters \a \1

    \! \space \newline \tab \\ Strings 'this is a string' Symbols $a $1 $mark $'hello world' Comments "this is a multi-line comment"
  11. SYNTAX (Message Patterns) fscript, apl AGES := [27. 51. 44.

    62. 53. 19. 23. 52. 21. 53. 35] "Are they all order than 20" AGES > 20 \ $& "False" "How many are over 25 but under 60" AGES > 25 & (AGES < 60) \ $+ "8"* * this works because Boolean objects implement the '+' behavior, so a Boolean can be added as if True were 1 and False 0 (once integers are implemented) "What is the percentage of people over 30" 100 * (AGES > 30 \ $+) / AGES count "63.64"
  12. SYNTAX (Attributes) ruby + Person firstName => { @firstName }

    '@firstName' is syntactic sugar for: self getAttribute: $firstName + Person firstName: aString => { @firstName := aString } '@firstName := aString' is syntactic sugar for: self setAttribute: $firstName to: aString
  13. STATE (byzantine) paxos*, ruby A family of protocols for solving

    consensus in a network of unreliable processors. Consensus is the process of agreeing on one result among a group of participants. "Reaching Agreement in the Presence of Faults" Leslie Lamport Journal of Association of Computing Machinery 1980 Google uses the Paxos algorithm in their Chubby distributed lock service in order to keep replicas consistent in the case of failure. Chubby is used by BigTable which is in production in Google Analytics and other products. *(out of the scope of this talk... and I'm still learning more about it)