SLIDE 1 ESOP 2016, Eindhoven, Netherlands; 20160405
Coordinated Concurrent Programming in
SYNDICATE
Tony Garnock-Jones ✉ Matthias Felleisen
tonyg@ccs.neu.edu matthias@ccs.neu.edu Northeastern University Northeastern University
SLIDE 2 How can we organise
SLIDE 3 How can we organise
With a programming language!
SLIDE 4 How can we organise
SYNDICATE
SLIDE 5
User Program Interactive System
SLIDE 6
User Program External Concurrency
SLIDE 7
User Program Lots of External Concurrency
SLIDE 8
User Program Lots of External Concurrency
Internal Organisation Reflects External Concurrency
SLIDE 9 User
with coordination + internal tasks
Program Lots of External Concurrency
Internal Organisation Reflects External Concurrency
SLIDE 10 A C B D
Networked Program
A B C D
with coordination + internal tasks
Lots of External Concurrency
Internal Organisation Reflects External Concurrency
SLIDE 11 A C E B D
Networked Program
A B C D
with coordination + internal tasks
Lots of Dynamic, External Concurrency
Component startup → interaction → shutdown/failure
SLIDE 12 A C E B D
Networked Program
A B C D E
with coordination + internal tasks
Lots of Dynamic, External Concurrency
Component startup → interaction → shutdown/failure
SLIDE 13 A C E B D
Networked Program
A B C D E
with coordination + internal tasks
Lots of Dynamic, External Concurrency
Component startup → interaction → shutdown/failure
SLIDE 14 A C E D
Networked Program
A B C D E
with coordination + internal tasks
Lots of Dynamic, External Concurrency
Component startup → interaction → shutdown/failure
SLIDE 15 A C E D
Networked Program
A C D E
with coordination + internal tasks
Lots of Dynamic, External Concurrency
Component startup → interaction → shutdown/failure
SLIDE 16
SLIDE 17
SYNDICATE
SLIDE 18
event × state → [action] × state
SLIDE 19 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42
SLIDE 20 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 Actor behaviour function private state unique internal ID
SLIDE 21 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 Dataspace: assertions + provenance
“Tuplespaces”
SLIDE 22 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 “I, actor #17, assert that the current score is 3.”
SLIDE 23 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 “I, actor #42, assert that the space key is currently held down.”
SLIDE 24 event × state → [action] × state
actor #17 actor #42
Actions carry assertions actor → environment
actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42
SLIDE 25 event × state → [action] × state
actor #17 actor #42
Events carry assertions environment → actor
actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42
SLIDE 26 event × state → [action] × state
actor #17 actor #42 actor #94
{ [sprite,player,51,100, ], ?[keyDown,★] } [currentScore,3] → actor #17 [keyDown,space] → actor #42
SLIDE 27 event × state → [action] × state
actor #17 actor #42 actor #94
{ [sprite,player,51,100, ], ?[keyDown,★] } [currentScore,3] → actor #17 [keyDown,space] → actor #42 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 28 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94 “I, actor #94, am interested in keeping track
- f assertions of the form [keyDown,★].”
SLIDE 29 event × state → [action] × state
actor #17 actor #42 actor #94
{ [keyDown,space] } [currentScore,3] → actor #17 [keyDown,space] → actor #42 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 30 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 31 event × state → [action] × state
actor #17 actor #42
{ }
actor #94
[currentScore,3] → actor #17 [keyDown,space] → actor #42 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 32 event × state → [action] × state
actor #17 actor #42
{ }
actor #94
[currentScore,3] → actor #17 [keyDown,space] actor #42 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 33 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 34 event × state → [action] × state
actor #17 actor #42 actor #94
{ } [currentScore,3] → actor #17 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 35 event × state → [action] × state
actor #17 actor #42 actor #94
[currentScore,3] → actor #17 [sprite,player,51,100, ] → actor #94 ?[keyDown,★] → actor #94
SLIDE 36 actor #42 actor #1
⟵ actor
#99
[keyDown,space] → actor #42
SLIDE 37 actor #42 actor #1
{ ?⇃[keyDown,★], ⇃?[keyDown,★] } ⟵ actor
#99
[keyDown,space] → actor #42
SLIDE 38 actor #42 actor #1
{ ?⇃[keyDown,★], ⇃?[keyDown,★] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42
SLIDE 39 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42 “I, actor #1, assert that I am interested in all key-down assertions at the next level out.”
SLIDE 40 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42 “I, actor #1, request my dataspace to assert ‘interest in all key-down assertions’
- n my behalf at the next level out.”
SLIDE 41 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42
SLIDE 42 actor #42 actor #1
{ ?[keyDown,★] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42
SLIDE 43 actor #42 actor #1
{ ?[keyDown,★] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 44 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 45 actor #42 actor #1
{ [keyDown,space] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 46 actor #42 actor #1
{ [keyDown,space] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⇃[keyDown,space] → ⇃ ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 47 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⇃[keyDown,space] → ⇃ ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99 “The next level out has informed us that the space key is being held down.”
SLIDE 48 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⇃[keyDown,space] → ⇃ ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 49 actor #42 actor #1
{ ⇃[keyDown,space] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⇃[keyDown,space] → ⇃ ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 50 actor #42 actor #1
?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⇃[keyDown,space] → ⇃ ⟵ actor
#99
[keyDown,space] → actor #42 ?[keyDown,★] → actor #99
SLIDE 51
Messages are transient assertions < [incrementScoreBy,3] > ~ { [incrementScoreBy,3] } followed by { }
SLIDE 52 General challenges of interactivity
- Mapping events to components
- Building a shared understanding
- Partial failure
- Scoped conversational state
SLIDE 53 General challenges of interactivity
- Mapping events to components
- Building a shared understanding
- Partial failure
- Scoped conversational state
SLIDE 54
Mapping events to components: OO
SLIDE 55
Mapping events to components: Actors
SLIDE 56
Mapping events to components: Syndicate
SLIDE 57 General challenges of interactivity
✓ Mapping events to components
- Building a shared understanding
- Partial failure
- Scoped conversational state
SLIDE 58
Building a shared understanding: OO
SLIDE 59
Building a shared understanding: OO
SLIDE 60
Building a shared understanding: OO
SLIDE 61
Building a shared understanding: OO
SLIDE 62
Building a shared understanding: Actors
SLIDE 63
Building a shared understanding: Syndicate
SLIDE 64 General challenges of interactivity
✓ Mapping events to components ✓ Building a shared understanding
- Partial failure
- Scoped conversational state
SLIDE 65
Partial Failure: OO & Actors
SLIDE 66
Partial Failure: OO & Actors
SLIDE 67 Partial Failure: OO & Actors
GamePiece GamePiece Store Physics Collision add_piece(P1) add_sub(L1) add_piece(P1) add_piece(P2) add_piece(P2) add_sub(L2) add_piece(P1) add_piece(P2)
SLIDE 68 Partial Failure: OO & Actors
GamePiece GamePiece Store Physics Collision add_piece(P1) add_sub(L1) add_piece(P1) add_piece(P2) add_piece(P2) add_sub(L2) add_piece(P1) add_piece(P2)
SLIDE 69 Partial Failure: OO & Actors
GamePiece GamePiece Store Physics Collision add_piece(P1) add_sub(L1) add_piece(P1) add_piece(P2) add_piece(P2) add_sub(L2) add_piece(P1) add_piece(P2)
SLIDE 70 Partial Failure: Actors (Erlang)
GamePiece GamePiece Store Physics Collision add_piece(P1) add_sub(L1) add_piece(P1) add_piece(P2) add_piece(P2) EXIT del_piece(P1)
SLIDE 71
Partial Failure: Syndicate
enemy collision (game-piece-state ...) → enemy ?(game-piece-state ★) → collision
SLIDE 72
Partial Failure: Syndicate
! collision (game-piece-state ...) → enemy ?(game-piece-state ★) → collision
SLIDE 73
Partial Failure: Syndicate
! collision (game-piece-state ...) enemy ?(game-piece-state ★) → collision
SLIDE 74
Partial Failure: Syndicate
collision { } ?(game-piece-state ★) → collision
SLIDE 75
Partial Failure: Syndicate
collision ?(game-piece-state ★) → collision
SLIDE 76 General challenges of interactivity
✓ Mapping events to components ✓ Building a shared understanding ✓ Partial failure
- Scoped conversational state
SLIDE 77
Scoped Conversational State: OO & Actors
SLIDE 78
Scoped Conversational State: OO & Actors
SLIDE 79
Scoped Conversational State: OO & Actors
SLIDE 80
Scoped Conversational State: OO & Actors
SLIDE 81
Scoped Conversational State: OO
SLIDE 82 Scoped Conversational State: Actors (Erlang/OTP)
“One-for-all” Supervision Supervisor Player Enemy Enemy Key
SLIDE 83 Scoped Conversational State: Actors (Erlang/OTP)
“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT
SLIDE 84 Scoped Conversational State: Actors (Erlang/OTP)
“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT KILL KILL KILL
SLIDE 85 Scoped Conversational State: Actors (Erlang/OTP)
“One-for-all” Supervision Supervisor Player Enemy Enemy Key
SLIDE 86 Scoped Conversational State: Actors (Erlang/OTP)
“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT
SLIDE 87 Scoped Conversational State: Actors (Erlang/OTP)
“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT KILL KILL KILL
SLIDE 88
Scoped Conversational State: Syndicate
SLIDE 89 Grade table
OO/Callbacks/Threads Actors SYNDICATE Mapping events to components ZERO ZERO OK Building a shared understanding ZERO OK− OK Partial failure ZERO OK− OK Scoped conversational state ZERO OK− OK ZERO → OK− → OK → OK+
SLIDE 90 Grade table
OO/Callbacks/Threads Actors SYNDICATE Mapping events to components Pattern-matching via assertions of interest ZERO ZERO OK Building a shared understanding ZERO OK− OK Partial failure ZERO OK− OK Scoped conversational state ZERO OK− OK ZERO → OK− → OK → OK+
SLIDE 91 Grade table
OO/Callbacks/Threads Actors SYNDICATE Mapping events to components ZERO ZERO OK Building a shared understanding The dataspace is the shared understanding! ZERO OK− OK Partial failure ZERO OK− OK Scoped conversational state ZERO OK− OK ZERO → OK− → OK → OK+
SLIDE 92 Grade table
OO/Callbacks/Threads Actors SYNDICATE Mapping events to components ZERO ZERO OK Building a shared understanding ZERO OK− OK Partial failure Automatic retraction of assertions ZERO OK− OK Scoped conversational state ZERO OK− OK ZERO → OK− → OK → OK+
SLIDE 93 Grade table
OO/Callbacks/Threads Actors SYNDICATE Mapping events to components ZERO ZERO OK Building a shared understanding ZERO OK− OK Partial failure ZERO OK− OK Scoped conversational state Nested dataspaces + controlled assertion flow between them ZERO OK− OK ZERO → OK− → OK → OK+
SLIDE 94 Grade table
OO/Callbacks/Threads Actors SYNDICATE Mapping events to components ZERO ZERO OK Building a shared understanding ZERO OK− OK Partial failure ZERO OK− OK Scoped conversational state ZERO OK− OK ZERO → OK− → OK → OK+
SLIDE 95
syn·di·cate
a language for interactive programs Actors + Dataspaces + Assertions + Nesting
Paper: − Formal semantics & basic properties − Incremental SCN protocol & equivalence thm − Tries for efficient dataspace implementation − Performance model & measurements − Case studies: TCP/IP stack, GUI widget
http://syndicate-lang.org/