How can we organise our interactive programs? How can we organise - - PowerPoint PPT Presentation

how can we organise our interactive programs how can we
SMART_READER_LITE
LIVE PREVIEW

How can we organise our interactive programs? How can we organise - - PowerPoint PPT Presentation

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


slide-1
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
SLIDE 2

How can we organise

  • ur interactive programs?
slide-3
SLIDE 3

How can we organise

  • ur interactive programs?

With a programming language!

slide-4
SLIDE 4

How can we organise

  • ur interactive programs?

SYNDICATE

slide-5
SLIDE 5

User Program Interactive System

slide-6
SLIDE 6

User Program External Concurrency

slide-7
SLIDE 7

User Program Lots of External Concurrency

slide-8
SLIDE 8

User Program Lots of External Concurrency

Internal Organisation Reflects External Concurrency

slide-9
SLIDE 9

User

with coordination + internal tasks

Program Lots of External Concurrency

Internal Organisation Reflects External Concurrency

slide-10
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
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
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
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
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
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 16
slide-17
SLIDE 17

SYNDICATE

slide-18
SLIDE 18

event × state → [action] × state

slide-19
SLIDE 19

event × state → [action] × state

actor #17 actor #42 actor #94

[currentScore,3] → actor #17 [keyDown,space] → actor #42

slide-20
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
SLIDE 21

event × state → [action] × state

actor #17 actor #42 actor #94

[currentScore,3] → actor #17 [keyDown,space] → actor #42 Dataspace: assertions + provenance

  • cf. Linda's

“Tuplespaces”

slide-22
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
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
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
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
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
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
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
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
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
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
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
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
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
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
SLIDE 36

actor #42 actor #1

⟵ actor

#99

[keyDown,space] → actor #42

slide-37
SLIDE 37

actor #42 actor #1

{ ?⇃[keyDown,★], ⇃?[keyDown,★] } ⟵ actor

#99

[keyDown,space] → actor #42

slide-38
SLIDE 38

actor #42 actor #1

{ ?⇃[keyDown,★], ⇃?[keyDown,★] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor

#99

[keyDown,space] → actor #42

slide-39
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
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
SLIDE 41

actor #42 actor #1

?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor

#99

[keyDown,space] → actor #42

slide-42
SLIDE 42

actor #42 actor #1

{ ?[keyDown,★] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor

#99

[keyDown,space] → actor #42

slide-43
SLIDE 43

actor #42 actor #1

{ ?[keyDown,★] } ?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor

#99

[keyDown,space] → actor #42 ?[keyDown,★] → actor #99

slide-44
SLIDE 44

actor #42 actor #1

?⇃[keyDown,★] → actor #1 ⇃?[keyDown,★] → actor #1 ⟵ actor

#99

[keyDown,space] → actor #42 ?[keyDown,★] → actor #99

slide-45
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
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
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
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
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
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
SLIDE 51

Messages are transient assertions < [incrementScoreBy,3] > ~ { [incrementScoreBy,3] } followed by { }

slide-52
SLIDE 52

General challenges of interactivity

  • Mapping events to components
  • Building a shared understanding
  • Partial failure
  • Scoped conversational state
slide-53
SLIDE 53

General challenges of interactivity

  • Mapping events to components
  • Building a shared understanding
  • Partial failure
  • Scoped conversational state
slide-54
SLIDE 54

Mapping events to components: OO

slide-55
SLIDE 55

Mapping events to components: Actors

slide-56
SLIDE 56

Mapping events to components: Syndicate

slide-57
SLIDE 57

General challenges of interactivity

✓ Mapping events to components

  • Building a shared understanding
  • Partial failure
  • Scoped conversational state
slide-58
SLIDE 58

Building a shared understanding: OO

slide-59
SLIDE 59

Building a shared understanding: OO

slide-60
SLIDE 60

Building a shared understanding: OO

slide-61
SLIDE 61

Building a shared understanding: OO

slide-62
SLIDE 62

Building a shared understanding: Actors

slide-63
SLIDE 63

Building a shared understanding: Syndicate

slide-64
SLIDE 64

General challenges of interactivity

✓ Mapping events to components ✓ Building a shared understanding

  • Partial failure
  • Scoped conversational state
slide-65
SLIDE 65

Partial Failure: OO & Actors

slide-66
SLIDE 66

Partial Failure: OO & Actors

slide-67
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
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
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
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
SLIDE 71

Partial Failure: Syndicate

enemy collision (game-piece-state ...) → enemy ?(game-piece-state ★) → collision

slide-72
SLIDE 72

Partial Failure: Syndicate

! collision (game-piece-state ...) → enemy ?(game-piece-state ★) → collision

slide-73
SLIDE 73

Partial Failure: Syndicate

! collision (game-piece-state ...) enemy ?(game-piece-state ★) → collision

slide-74
SLIDE 74

Partial Failure: Syndicate

collision { } ?(game-piece-state ★) → collision

slide-75
SLIDE 75

Partial Failure: Syndicate

collision ?(game-piece-state ★) → collision

slide-76
SLIDE 76

General challenges of interactivity

✓ Mapping events to components ✓ Building a shared understanding ✓ Partial failure

  • Scoped conversational state
slide-77
SLIDE 77

Scoped Conversational State: OO & Actors

slide-78
SLIDE 78

Scoped Conversational State: OO & Actors

slide-79
SLIDE 79

Scoped Conversational State: OO & Actors

slide-80
SLIDE 80

Scoped Conversational State: OO & Actors

slide-81
SLIDE 81

Scoped Conversational State: OO

slide-82
SLIDE 82

Scoped Conversational State: Actors (Erlang/OTP)

“One-for-all” Supervision Supervisor Player Enemy Enemy Key

slide-83
SLIDE 83

Scoped Conversational State: Actors (Erlang/OTP)

“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT

slide-84
SLIDE 84

Scoped Conversational State: Actors (Erlang/OTP)

“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT KILL KILL KILL

slide-85
SLIDE 85

Scoped Conversational State: Actors (Erlang/OTP)

“One-for-all” Supervision Supervisor Player Enemy Enemy Key

slide-86
SLIDE 86

Scoped Conversational State: Actors (Erlang/OTP)

“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT

slide-87
SLIDE 87

Scoped Conversational State: Actors (Erlang/OTP)

“One-for-all” Supervision Supervisor Player Enemy Enemy Key EXIT KILL KILL KILL

slide-88
SLIDE 88

Scoped Conversational State: Syndicate

slide-89
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
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
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
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
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
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
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/