Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WTF is Reactive Programming

830 views

Published on

This will be a journey through the evolution of both the definition and implementations of Reactive Programming and how they have been converging in a quest to make building responsive applications a sane process.

We are still at the point where there is no complete consensus on what a reactive application is; I will explore how this consensus is evolving and what problems it brings.

I am going to talk about the past, present and possible futures of reactive programming and how you can survive it all.

This talk was made at http://2017.progscon.co.uk/

Published in: Software
  • Be the first to comment

  • Be the first to like this

WTF is Reactive Programming

  1. 1. WTF is Reactive Programming? Evgeny Poberezkin @epoberezkin
  2. 2. reactive /rɪˈaktɪv/ adjective 1. showing a response to a stimulus. "pupils are reactive to light" 2. acting in response to a situation rather than creating or controlling it. "a proactive rather than a reactive approach"
  3. 3. Is Reactive Manifesto the answer?
  4. 4. 1971 The best way to predict the future is to invent it
  5. 5. 1973 Xerox Alto Alan Kay
  6. 6. The Reactive Engine “the machines which can participate in an interactive dialogue”
  7. 7. TheReactiveEngine
  8. 8. 1970-80s: Data Flow Programming Paul Kosinski goo.gl/0aMNZu Jack Dennis goo.gl/lEI788
  9. 9. 1985: Reactive systems On the development of reactive systems goo.gl/dbECw8 D. Harel and A. Pnueli from The Weizmann Institute • Transformational vs reactive systems • Describing reactive systems • The development of a reactive system
  10. 10. Describing reactive systems Events & conditions States and transitions Output events
  11. 11. Developing reactive systems Transformational system Specification Design Reactive system Start point Behaviour (specify) Final system Implementation (design)
  12. 12. 1991: Reactive Programming Three paradigms: 1. Events update the state goo.gl/5tm66t 2. The state satisfies constraints goo.gl/vr2V3F 3. Processing event streams goo.gl/XcFgQL
  13. 13. 1. Events modify the state • External events (activations) • Reactions Frédéric Boussinot Reactive C: An Extension of C Reactive Systems
  14. 14. Temperature converter 1 Implicit data graph: C.observe(c => F.set(c * 1.8 + 32)); F.observe(f => C.set((f - 32) / 1.8));
  15. 15. 2. The state should satisfy constraints Bruce L. Horn Siri : a constrained-object language for reactive program implementation • Visual metaphors • Direct manipulation • Reflection of changes in the data
  16. 16. Temperature converter 2 Explicit data graph: F  C * 1.8 + 32
  17. 17. 3. Processing event streams John Plaice RLucid, a general real-time dataflow language "Stream processing is natural to reactive programming"
  18. 18. Temperature converter 3 Manipulating streams: F = C.map(c => c * 1.8 + 32) C1 = F1.map(f => (f-32) / 1.8)
  19. 19. 1991: Reactive Programming Three paradigms: 1. Events update the state 2. The state satisfies constraints 3. Processing event streams
  20. 20. 1997: Functional RP FRAN – Functional Reactive Animations goo.gl/2SR0cQ Modelling: 1. Temporal modelling – Behaviours/signals 2. Events modelling 3. Declarative reactivity 4. Polymorphic views
  21. 21. FRP: Events and behaviours
  22. 22. 2000s: Reactive programming Constraints based approach focussed on constraints Libraries: • Trellis – python • Cells – Common lisp
  23. 23. Most used RP implementation
  24. 24. 2007: RP Wikipedia page Robert Wensman a:= b + c
  25. 25. 2012: Survey on RP RP = abstraction over time management The most comprehensive non-JS survey goo.gl/0Dhvnm Compares: • 2 categories: FRP siblings and RP cousins • Evaluation model: push/pull • Lifting • Multidirectional • Glitch avoidance • Distributed model
  26. 26. RP: lifting • Implicit: f(B) • Explicit: lift(f)(B) • Manual: f(current(B))
  27. 27. RP: Glitch x1 = seconds x2 = x1 * 1 x3 = x1 + x2 seconds x1 + x2 x1 + x2 (glitch) 0 0 0 1 2 1 2 4 3
  28. 28. JavaScript frameworks Event based • React + Flux/Redux FRP • ReactiveX • Bacon.js Data-flow / Constraints based • angular • vuejs • alkali • milo
  29. 29. alkali const cToF = c => c * 1.8 + 32; cToF.reverse = (f, inputs) => inputs[0].put((f.valueOf() - 32) / 1.8) let tempC = new Variable(0); let tempF = tempC.to(cToF); console.log(tempF.valueOf()); // 32 tempF.put(100); console.log(tempC.valueOf()); // 37.8
  30. 30. Summary Conflicting paradigms Incomplete implementations Opportunity for innovation
  31. 31. Future possibilities Non-deterministic streams Generational neural networks Quantum computing
  32. 32. Questions? Evgeny.Poberezkin@mailonline.co.uk @epoberezkin

×