actor thinking
play

Actor Thinking Dale Schumacher twitter: @dalnefre QCon/SF 2010-11 - PowerPoint PPT Presentation

Actor Thinking Dale Schumacher twitter: @dalnefre QCon/SF 2010-11 Conway's Law ... organizations which design systems are constrained to produce designs which are copies of the communication structures of these organizations.


  1. Actor Thinking Dale Schumacher twitter: @dalnefre QCon/SF 2010-11

  2. Conway's Law “... organizations which design systems … are constrained to produce designs which are copies of the communication structures of these organizations.” –M. Conway (1968)

  3. Models of Computation Functions Procedures Functions Procedures Actors Actors Objects Objects Logic Dataflow Logic Dataflow

  4. Sequential Stack Machine JZ +6 6 IP SP ROLL -3 1 ADD 2 SWAP 3 DEC 5 JMP -5 8 POP 13

  5. Linked Stack Machine IP SP ZERO? 5 ROLL -3 1 ADD 2 SWAP 3 DEC 5 POP 8

  6. Actors and Functions “Hewitt had noted that the actor model could capture the salient aspects of the lambda calculus; Scheme demonstrated that the lambda calculus captured nearly all salient aspects (excepting only side effects and synchronization) of the actor model.” –G. Steele and R. Gabriel (1993)

  7. Objects (Kay) & Actors (Hewitt) ● Everything is an object ● Configuration = actors + messages ● Objects communicate ● Actors respond to by sending and receiving messages messages by: ● Objects have their own  Sending messages memory  Creating actors ● Inheritance?  Changing behavior Polymorphism? ● Everything is concurrent

  8. It's all about the messages Actors Actors Objects Objects Messages

  9. http://www.flickr.com/photos/sunface13/4815937062/

  10. λ ( L E T ring_builder ( n ) = first , m ) . [ C A S E n O F ring ( ring , 3) 0 : [ λ m . B E C O M E [ # ring_last ( first ) next C A S E m O F ring_link build(4) λ _ 0 : [ B E C O M E . [ ] ] _ : [ S E N D dec ( m ) T O first ] E N D ( ring , 3) first ] S E N D m T O first ring_last build(0) ring_link build(3) ] _ : [ next ( ring , 3) C R E A T E next WI T H ring_builder ( dec ( n ) ) S E N D ( first , m ) T O next ( ring , 3) λ m . B E C O M E [ # ring_link ( next ) next S E N D m T O next ] ring_link build(1) ring_link build(2) ] ( ring , 3) E N D next ] C R E A T E ring WI T H ring_builder ( 4 ) S E N D ( ring , 3 ) T O ring

  11. λ ( L E T ring_builder ( n ) = first , m ) . [ C A S E n O F ring 0 : [ λ m . B E C O M E [ # ring_last ( first ) next C A S E m O F ring_link λ _ 0 : [ B E C O M E . [ ] ] 3 2 1 0 _ : [ S E N D dec ( m ) T O first ] E N D 2 3 1 0 first ] S E N D m T O first λ _ ring_last . [ ] ring_link ] _ : [ next 0 1 2 3 C R E A T E next WI T H ring_builder ( dec ( n ) ) S E N D ( first , m ) T O next 3 0 1 2 λ m . B E C O M E [ # ring_link ( next ) next S E N D m T O next ] ring_link ring_link ] 3 0 1 2 E N D next ] C R E A T E ring WI T H ring_builder ( 4 ) S E N D ( ring , 3 ) T O ring

  12. Object-Capability Security # s e r v i c e p r o t o c o l : ( cust , { # c r e a t e , # r e a d , # u p d a t e , # d e l e t e } , key [ , value ] ) λ ( L E T read_only_proxy_beh ( service ) = cust , req ) . [ C A S E req O F ( # r e a d , key ) : [ S E N D ( cust , req ) T O service ] proxy service _ : [ S E N D ? T O cust ] E N D ] λ ( L E T revocable_delete_proxy_beh ( service , owner ) = cust , req ) . [ owner C A S E req O F ( # d e l e t e , key ) : [ S E N D ( cust , req ) T O service ] ( # r e v o k e , $ owner ) : [ S E N D # r e v o k e d T O cust ] _ : [ S E N D ? T O cust ] proxy service E N D λ ( B E C O M E cust , _ ) . [ S E N D ? T O cust ] ]

  13. Lifetimes vary dramatically

  14. λ ( C R E A T E empty_grammar WI T H cust , # m a t c h , src ) . [ empty S E N D ( T R U E , N I L , src ) T O cust ] λ ( L E T symbol_grammar_beh ( symbol ) = cust , # m a t c h , src ) . [ S E N D ( k_symbol , # r e a d ) T O src λ ( symbol C R E A T E k_symbol WI T H token , next ) . [ C A S E token O F $ symbol : [ S E N D ( T R U E , token , next ) T O cust ] _ : [ S E N D ( F A L S E , src ) T O cust ] k_symbol E N D ] ] λ ( L E T alt_grammar_beh ( first , rest ) = cust , # m a t c h , src ) . [ ... S E N D ( k_alt , # m a t c h , src ) T O first first λ match . C R E A T E k_alt WI T H [ alt C A S E match O F rest ( T R U E , _ ) : [ S E N D match T O cust ] ... _ : [ S E N D ( cust , # m a t c h , src ) T O rest ] k_alt E N D ] ]

  15. λ ( L E T seq_grammar_beh ( first , rest ) = cust , # m a t c h , src ) . [ S E N D ( k_seq , # m a t c h , src ) T O first ... λ match . C R E A T E k_seq WI T H [ first C A S E match O F seq ( T R U E , token , next ) : [ rest S E N D ( S E L F , # m a t c h , next ) T O rest ... λ match' . B E C O M E [ k_seq C A S E match' O F ( T R U E , token' , next' ) : [ S E N D ( T R U E , ( token , token' ) , next' ) T O cust ] k_seq' _ : [ S E N D ( F A L S E , src ) T O cust ] E N D ] ] _ : [ S E N D ( F A L S E , src ) T O cust ] E N D ] ]

  16. λ msg . L E T opt_grammar_beh ( grammar ) = [ # o p t : : = < g r a m m a r > | < e m p t y > ; grammar B E C O M E alt_grammar_beh ( first grammar , alt empty_grammar rest ) empty S E N D msg T O S E L F ] λ msg . L E T star_grammar_beh ( grammar ) = [ # s t a r : : = < g r a m m a r > < s t a r > | < e m p t y > ; grammar rest B E C O M E seq_grammar_beh ( first N E W seq_grammar_beh ( grammar , S E L F ) , seq first empty_grammar seq ) S E N D msg T O S E L F rest empty ] λ msg . L E T plus_grammar_beh ( grammar ) = [ # p l u s : : = < g r a m m a r > < g r a m m a r > * ; B E C O M E seq_grammar_beh ( grammar first grammar , seq N E W star_grammar_beh ( grammar ) ) rest star(...) S E N D msg T O S E L F ]

  17. Un-typed Lambda Calculus expr ::= <const> | <ident> | ' λ ' <ident> '.' <expr> | <expr> '(' <expr> ')';

  18. λ ( C R E A T E empty_env WI T H cust , _ ) . [ S E N D ? T O cust ] λ ( L E T env_beh ( ident , value , next ) = cust , ident' ) . [ I F $ ident' = $ ident [ S E N D value T O cust ] E L S E [ S E N D ( cust , ident' ) T O next ] ] λ ( L E T const_expr_beh ( value ) = cust , # e v a l , _ ) . [ S E N D value T O cust ] λ ( L E T ident_expr_beh ( ident ) = cust , # e v a l , env ) . [ S E N D ( cust , ident ) T O env ] λ ( L E T abs_expr_beh ( ident , body_expr ) = cust , # e v a l , env ) . [ λ ( C R E A T E closure WI T H cust , # a p p l y , arg ) . [ C R E A T E env' WI T H env_beh ( ident , arg , env ) S E N D ( cust , # e v a l , env' ) T O body_expr ] S E N D closure T O cust ] λ ( L E T app_expr_beh ( abs_expr , arg_expr ) = cust , # e v a l , env ) . [ S E N D ( k_abs , # e v a l , env ) T O abs_expr λ abs . C R E A T E k_abs WI T H [ S E N D ( k_arg , # e v a l , env ) T O arg_expr λ arg . C R E A T E k_arg WI T H [ S E N D ( cust , # a p p l y , arg ) T O abs ] ] ]

  19. Evaluating ( λ x . x )(42)

  20. Open Systems ● Continuous Change and Evolution ● Decentralized Decision-Making – Absence of Bottlenecks – Arms-length Relationships ● Perpetual Inconsistency ● Negotiation Among Components –C. Hewitt and P. de Jong (1983)

  21. References It's Actors All The Way Down <http://dalnefre.com/> ● C. Hewitt. Viewing Control Structures as Patterns of Passing ● Messages. Journal of Artificial Intelligence , 8(3), 1977. G. Agha. Actors: A Model of Concurrent Computation in ● Distributed Systems . MIT Press, Cambridge, MA, 1986. C. Hewitt, H. Lieberman. Design Issues in Parallel Architectures ● for Artificial Intelligence. AI Memo 750, MIT AI Lab, 1983. G. Agha, I. Mason, S. Smith, and C. Talcott. A Foundation for ● Actor Computation. Journal of Functional Programming , Vol. 7, No. 1, January 1997.

Recommend


More recommend