ESOP 2016, Eindhoven, Netherlands; 20160405 Coordinated Concurrent Programming in S YNDICATE Tony Garnock-Jones ✉ Matthias Felleisen tonyg@ccs.neu.edu matthias@ccs.neu.edu Northeastern University Northeastern University
How can we organise our interactive programs?
How can we organise our interactive programs? With a programming language!
How can we organise our interactive programs? S YNDICATE
Program User Interactive System
Program User External Concurrency
Program User Lots of External Concurrency
Program User Lots of External Concurrency Internal Organisation Re fl ects External Concurrency
Program with coordination + internal tasks User Lots of External Concurrency Internal Organisation Re fl ects External Concurrency
A A B B Networked C C Program D D with coordination + internal tasks Lots of External Concurrency Internal Organisation Re fl ects External Concurrency
A A B B Networked C C Program D D with coordination + internal tasks E Lots of Dynamic, External Concurrency Component startup → interaction → shutdown/failure
A A B B Networked C C Program D D with coordination + internal tasks E E Lots of Dynamic, External Concurrency Component startup → interaction → shutdown/failure
A A B B Networked C C Program D D with coordination + internal tasks E E Lots of Dynamic, External Concurrency Component startup → interaction → shutdown/failure
A A B Networked C C Program D D with coordination + internal tasks E E Lots of Dynamic, External Concurrency Component startup → interaction → shutdown/failure
A A Networked C C Program D D with coordination + internal tasks E E Lots of Dynamic, External Concurrency Component startup → interaction → shutdown/failure
S YNDICATE
event × state → [action] × state
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 Actor behaviour function private state unique internal ID
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 cf. Linda's Dataspace: assertions + provenance “Tuplespaces”
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 “I, actor #17, assert that the current score is 3.”
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 “I, actor #42, assert that the space key is currently held down.”
event × state → [action] × state Actions carry assertions actor → environment actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42
event × state → [action] × state Events carry assertions environment → actor actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42
event × state → [action] × state { [sprite,player,51,100, ], ?[keyDown, ★ ] } actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42
event × state → [action] × state { [sprite,player,51,100, ], ?[keyDown, ★ ] } actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state actor actor actor “I, actor #94, am interested in keeping track #17 #42 #94 of assertions of the form [keyDown, ★ ] .” [currentScore,3] → actor #17 [keyDown,space] → actor #42 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state { [keyDown,space] } actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state { } actor actor actor #17 #42 #94 [currentScore,3] → actor #17 [keyDown,space] → actor #42 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state { } actor actor actor #17 #42 #94 [currentScore,3] → actor #17 actor #42 [keyDown,space] ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state { } actor actor actor #17 #42 #94 [currentScore,3] → actor #17 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
event × state → [action] × state actor actor actor #17 #42 #94 [currentScore,3] → actor #17 ] → actor #94 [sprite,player,51,100, ?[keyDown, ★ ] → actor #94
actor #1 actor #42 ⟵ actor #99 [keyDown,space] → actor #42
{ ? ⇃ [keyDown, ★ ], ⇃ ?[keyDown, ★ ] } actor #1 actor #42 ⟵ actor #99 [keyDown,space] → actor #42
{ ? ⇃ [keyDown, ★ ], ⇃ ?[keyDown, ★ ] } actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 [keyDown,space] → actor #42
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 “I, actor #1, assert that I am interested in all key-down assertions [keyDown,space] → actor #42 at the next level out. ”
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 “I, actor #1, request my dataspace to [keyDown,space] → actor #42 assert ‘interest in all key-down assertions’ on my behalf at the next level out.”
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 [keyDown,space] → actor #42
actor #1 { ?[keyDown, ★ ] } ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 [keyDown,space] → actor #42
actor #1 { ?[keyDown, ★ ] } ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
actor #1 { [keyDown,space] } ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
actor #1 { [keyDown,space] } ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor ⇃ [keyDown,space] → ⇃ #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor ⇃ [keyDown,space] → ⇃ #99 [keyDown,space] → actor #42 “The next level out has informed us ?[keyDown, ★ ] → actor #99 that the space key is being held down.”
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor ⇃ [keyDown,space] → ⇃ #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
{ ⇃ [keyDown,space] } actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor ⇃ [keyDown,space] → ⇃ #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
actor #1 ? ⇃ [keyDown, ★ ] → actor #1 actor ⇃ ?[keyDown, ★ ] → actor #1 #42 ⟵ actor ⇃ [keyDown,space] → ⇃ #99 [keyDown,space] → actor #42 ?[keyDown, ★ ] → actor #99
Messages are transient assertions < [incrementScoreBy,3] > ~ { [incrementScoreBy,3] } followed by { }
General challenges of interactivity • Mapping events to components • Building a shared understanding • Partial failure • Scoped conversational state
General challenges of interactivity • Mapping events to components • Building a shared understanding • Partial failure • Scoped conversational state
Mapping events to components: OO
Mapping events to components: Actors
Mapping events to components: Syndicate
General challenges of interactivity ✓ Mapping events to components • Building a shared understanding • Partial failure • Scoped conversational state
Building a shared understanding: OO
Building a shared understanding: OO
Building a shared understanding: OO
Building a shared understanding: OO
Building a shared understanding: Actors
Building a shared understanding: Syndicate
Recommend
More recommend