modeling process
play

Modeling Process Rich Hickey Which are more fundamental? - PowerPoint PPT Presentation

Modeling Process Rich Hickey Which are more fundamental? Messages, classes, encapsulation, inheritance, dispatch... Time, value, identity, state, persistence, transience, place, perception, visibility, memory, process... Coming to


  1. Modeling Process Rich Hickey

  2. Which are more fundamental? • Messages, classes, encapsulation, inheritance, dispatch... • Time, value, identity, state, persistence, transience, place, perception, visibility, memory, process...

  3. Coming to Terms Value State • An immutable • Value of an identity at a magnitude, quantity, moment in time number... or immutable Time composite thereof • Relative before/after Identity ordering of causal values • A putative entity we associate with a series of causally related values (states) over time

  4. A Real Problem

  5. Place • “open space” • Relative • Include time coordinate, and process results happen in new places

  6. What Would a Program Do? Not this!

  7. Are places in charge?

  8. What do we see?

  9. Our Problem Reality Perception Memory Logic

  10. Perception • Perceive - “take entirely” • Sensory systems only ever perceive the past • Discretizing, snapshots • Most useful when coupled with memory • Fidelity matters • Visible == “can be perceived” • not merely ‘reachable via reference’

  11. Memory • “mindful, remembering” • If our mental memory behaved the way we use computer memory, we’d be ill • In the mind we talk about forming memories • New memories about the same identities don’t replace the old • Fidelity matters • Stability matters (persistence)

  12. Program Memory • Sometimes we use computer memory like brain memory • Sometimes like perception • Sometimes (commonly, most of the time) like places

  13. Using the same memory for everything • Destroys the past • Corrupts remembering • Interferes with perception • We must use memory for all three things, but not necessarily the same memory

  14. Process

  15. Process • “go forward, advance” • They’re not called “food calculators” • Potentially richer than this • Manipulate contents of place(s) • May involve multiple forces

  16. Process across multiple places

  17. Process with multiple forces/participants

  18. Philosophy • Things don't change in place • Becomes obvious once you incorporate time as a dimension • Place includes time • The future is a (multi-force) function of the past • Co-located entities can observe each other without cooperation • Coordination is desirable in local context

  19. Epochal Time Model Process events (pure functions*) � � � � � � � � � � � States Identity (immutable values) (succession of states) Observers/perception/memory

  20. Persistent • “lasting or enduring tenaciously” • Root: “to stand firm permanently” • When applied to data structures • A) safe on the disk (not today’s topic) • B) immutable++ • Great fit for perceptions and memories

  21. Identity Constructs as Gatekeepers of Time • Responsible for coherent successive states • Multiple semantics possible • And providing proper values to observers • Support coordination (multiple places) and process functions supplied from multiple threads of control (multiple participants)

  22. Functional Model Fn + args v2 v3

  23. CAS as Time Construct F vN+1 vN F F vNs v2 v3 v4 AtomicReference • 1:1 timeline/identity • Atomic state succession (swap! an-atom f args) • Point-in-time value (f vN args) becomes vN+1 perception - can automate spin 23

  24. Agents as Time Construct F F F F F F vN+1 vN a r g s ) ( s e n d a r e f f vNs returns immediately queue enforces serialization • 1:1 timeline/identity ) becomes vN+1 ( f v N a r g s • Atomic state succession happens asynchronously in • Point-in-time value thread pool thread perception 24

  25. STM as Time Construct v3 v4 v1 v2 v1 v2 v3 v4 v2 v3 v4 v1 v2 v3 v4 v1 F F F F Transactions F F F F F F F F 25

  26. But... • What if my logical unit of work involves a million steps? • Creating a million interim values via pure function invocation is a waste • “I’m going back to my cubbyholes!”

  27. Transient • “not lasting, enduring, or permanent; transitory” • Root: “go across” • When applied to data structures: • Not persistent! • Each operation returns the next transient • Can’t presume modify-in-place • Doesn’t preclude it either • No identity

  28. Transient-Based Model Proc r o c P + args a r g s + Make Transient Make Persistent (in new memory) (immutable) can be O(1) can be O(1) v2 aTransient aTransient v3 aTransient

  29. What about those Procs? • Might modify their arguments • Isn’t this just icky mutable side-effecting coding again? • hard to test • difficult to reason about • No!

  30. Proc • Function of transient to transient • Like pure function, can’t effect the world nor be effected by it • Only used in a context where transient cannot leak • Can always be sandwiched in value->transient and transient->value functions and become ‘pure’ Pure Function value V->T Proc T->V value

  31. The sweet, creamy, efficient middle of pure functions

  32. Transient/Proc Model • Prototype implementation - ‘pods’ • Can support multiple participants, in multiple threads • and coordination of multiple identities/places • even ad hoc grouping • But not arbitrary composition/nesting • Same limitation as locks, but detectable • Agents could support as well

  33. Summary • We need to talk about these things • Better, more precise language and terms • Language and library support • Examine high-level abstractions and constructs in terms of these fundamental issues

  34. Thanks for listening! http://clojure.org

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend