Time and Concurrency

74bff20b7f21728b504dacb6255dee6d?s=47 Jason Lewis
September 30, 2015

Time and Concurrency

Presentation for Baltimore Innovation Week 2015 DevDay.
Original Reveal.js slides at http://decomplecting.org/time-and-concurrency

74bff20b7f21728b504dacb6255dee6d?s=128

Jason Lewis

September 30, 2015
Tweet

Transcript

  1. TIME AND CONCURRENCY PROGRAMMING PARADIGMS AND THE FAILURE OF STATE

    Jason Lewis @canweriotnow Yet Analytics
  2. HELLO I think I was destined to become a functional

    programmer.
  3. Some years ago

  4. I spraypainted liked graffiti like this...

  5. ...and ended up here.

  6. TIME WE HAVE PROBLEMS WITH: State Value Identity

  7. You could not step twice into the same river. —

    Heraclitus of Ephesus
  8. PROBLEMS ARE BOTH: In our programs In our datastores

  9. THERE ARE SOLUTIONS Clojure Datomic (of which these are but

    two)
  10. WHAT IS IT?

  11. AN EXPERT EXPLAINS 0:18

  12. TIME PERCEPTION

  13. REALITY

  14. CONCURRENCY Really, ( > = t h i n g

    s 3 ) Concurrency Parallellism Distributed systems ...
  15. CONCURRENCY Object-Oriented (stateful): Stateful objects Mutexes and locking No (realistic)

    notion of time
  16. None
  17. Functional: Pure fns are timeless Zero state Run anywhen, anywhere,

    same result
  18. None
  19. CLOJURE(SCRIPT) Emphasis on pure functions Persistent data structures Side-effects are

    allowed State is managed
  20. Web programming IS distributed systems programming.

  21. Even in the simplest web application, we need to consider

    at least 3 things: the server, the browser, and the user.
  22. One language, two hosts: JVM (server) JS (browser)

  23. Code Sharing ( d e f n s t r

    - > i n t [ s ] # ? ( : c l j ( j a v a . l a n g . I n t e g e r / p a r s e I n t s ) : c l j s ( j s / p a r s e I n t s ) ) )
  24. DATOMIC EAVT tuple store database. ACID transactions. Immutable data =

    strong consistency + horizontal read scalability. Writes are not update-in-place; all data is retained by default. Makes time part of the database itself.
  25. BIG WIN: TIME TRAVEL

  26. Since Datomic retains the history of the db state, we

    can query the db as-of any given point in time. Since it treats the db as a value, and uses the same persistent data structures as Clojure itself, we can also query the future, by joining arbitrary data to a given db value.
  27. IT GETS BETTER... ( q ' [ : f i

    n d ? t i t l e : w h e r e [ ? e : m o v i e / y e a r 1 9 8 7 ] [ ? e : m o v i e / t i t l e ? t i t l e ] ] ) Datomic's datalog queries are just vectors, which means they can be passed around like any other of Clojure's persistent data structures... even from the browser to the server.
  28. PUTTING IT ALL TOGETHER

  29. None
  30. Pure functions acting on immutable data structures shared between client

    and server. Peers keep a hot copy of the db as a value in memory Reads and writes are orthogonal
  31. Time = λ

  32. Baltimore Clojure Meetup http://is.gd/baltimoreclojure

  33. THANK YOU! Jason Lewis Yet Analytics @canweriotnow jason@yetanalytics.com