Social Machines is a server-side programming language with a syntax greatly inspired by Smalltalk. Every object in Social Machines is a concurrent unit of computation, and libraries can be shared like peers in a BitTorrent network.
Social Machines is an exercise (read 'experiment') in language design and the evaluation of assumptions. The two assumptions that affected the design are as follows:
- Every object is an isolated, concurrent unit, easing the burden on the programmer by removing the need to choose whether to thread code or not.
- All modern computer languages are designed in the context that a language is designed for writing a single application running on a single machine. The network is an afterthought and therefore relegated to APIs. This is invalid due to the ubiquity of the internet.
The core of Social Machines is Carl Hewitt's Actor Model. All Social Machines objects exhibit three core behaviors:
- Create Objects
- Send Messages
- Receive Messages
All message passing in the Actor Model was done asynchronously. To make a program slightly easier to reason about, Social Machines adds Promises. All Social Machines Promises are first class. Promises allow the source to behave sequentially at the potential expense of dead locks/live locks.
The syntax is greatly inspired by Smalltalk. An example of the True
object is listed below. The +
indicates the defining of an External Behavior.
+ True ifFalse: fBlock -> Nil.
+ True ifTrue: tBlock -> tBlock value.
+ True ifTrue: tBlock ifFalse: fBlock -> tBlock value.
+ True not -> False.
+ (t True) & aBool ->
aBool ifTrue: { t } ifFalse: { False }.
+ (t True) | aBool -> t.
+ (t True) ^ aBool ->
aBool ifTrue: { False } ifFalse: { t }.
$ git clone https://github.com/socialmachines/socialmachines.git
$ mkdir ~/socialmachines/bin ~/socialmachines/pkg
$ export GOPATH=$GOROOT:$HOME/socialmachines
$ export PATH=$PATH:$GOROOT/bin
$ cd ~/socialmachines/src/soma
$ go install
$ soma
$ cd ~/socialmachines/src/test
$ go test
Social Machines source code is released under the MIT License with parts under Go's BSD-style license.
Refer to the legal/MIT and legal/BSD files for more information.