e01.org

reactive programming

In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change. With this paradigm, it is possible to express static (e.g., arrays) or dynamic (e.g., event emitters) data streams with ease, and also communicate that an inferred dependency within the associated execution model exists, which facilitates the automatic propagation of the changed data flow. For example, in imperative programming, a := b + c would mean that a is being assigned the result of b + c at the time the expression is evaluated, and later, the values of b and c can be changed with no effect on the value of a . In contrast, in reactive programming, the value of a is automatically updated whenever the values of b or c change, without the program having to explicitly re-state the statement a := b + c to re-assign the value of a .…

In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change. With this paradigm, it is possible to express static (e.g., arrays) or dynamic (e.g., event emitters) data streams with ease, and also communicate that an inferred dependency within the associated execution model exists, which facilitates the automatic propagation of the changed data flow. For example, in imperative programming, a := b + c would mean that a is being assigned the result of b + c at the time the expression is evaluated, and later, the values of b and c can be changed with no effect on the value of a . In contrast, in reactive programming, the value of a is automatically updated whenever the values of b or c change, without the program having to explicitly re-state the statement a := b + c to re-assign the value of a . int b = 1; int c = 2; int a = b + c; b = 10; System.out.println(a); // 3 (not 12 because "=" is not a reactive assignment operator) // now imagine a special operator "$=" exists that changes the value of a variable (executes code on the right side of the operator and assigns result to left side variable) whenever explicitly initialized, and when referenced variables (on the right side of the operator) are changed int b = 1; int c = 2; int a $= b + c; b = 10; System.out.println(a); // 12 Another example is a hardware description language such as Verilog, where reactive programming enables changes to be modeled as they propagate through circuits. Reactive programming has been proposed as a way to simplify creating interactive user interfaces and near-real-time computing animation. For example, in a model–view–controller (MVC) architecture, reactive programming can facilitate changes in an underlying model being reflected automatically in an associated view. t = seconds + 1 g = (t > seconds) Because t should always be greater than seconds , this expression should always evaluate to a true value. Unfortunately, this can depend on the order of evaluation. When seconds changes, two expressions have to update: seconds + 1 and the conditional. If the first evaluates before the second, then this invariant will hold. If, however, the conditional updates first, using the old value of t and the new value of seconds , then the expression will evaluate to a false value. This is called a glitch. Some reactive languages are glitch-free and prove this property. This is usually achieved by topologically sorting expressions and updating values in topological order. This can, however, have performance implications, such as delaying the delivery of values (due to the order of propagation). In some cases, therefore, reactive languages permit glitches, and developers must be aware of the possibility that values may temporarily fail to correspond to the program source, and that some expressions may evaluate multiple times (for instance, t > seconds may evaluate twice: once when the new value of seconds arrives, and once more when t updates). t = if ((seconds mod 2) == 0): seconds + 1 else: seconds - 1 end t + 1 Every second, the value of this expression changes to a different reactive expression, which t + 1 then depends on. Therefore, the graph of dependencies updates every second. Permitting dynamic updating of dependencies provides significant expressive power (for instance, dynamic dependencies routinely occur in graphical user interface (GUI) programs). However, the reactive update engine must decide whether to reconstruct expressions each time, or to keep an expression's node constructed but inactive; in the latter case, ensure that they do not participate in the computation when they are not supposed to be active. A n →B n →A n+1 , A n →C n →A n+1 , where n=1,2... This problem could be overcome by propagating invalidation only when some data is not already invalidated, and later re-validate the data when needed using lazy evaluation. One inherent problem for reactive programming is that most computations that would be evaluated and forgotten in a normal programming language, needs to be represented in the memory as data-structures. This could potentially make reactive programming highly memory consuming. However, research on what is called lowering could potentially overcome this problem. On the other side, reactive programming is a form of what could be described as "explicit parallelism" , and could therefore be beneficial for using the power of parallel hardware. ==References==

References

  1. ^ Shibanai, Kazuhiro; Watanabe, Takuo (2018). "Distributed Functional Reactive Programming on Actor-Based Runtime". Proceedings of the 8th ACM SIGPLAN International Workshop on Programming Based on Actors, Agents, and Decentralized Control . Agere 2018. pp. 13– 22. doi : 10.1145/3281366.3281370 . ISBN 9781450360661 . S2CID 53113447 . Archived from the original on 2021-06-24 . Retrieved 2021-06-24 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1624489200.0
  2. ^ "Embedding Dynamic Dataflow in a Call-by-Value Language" . cs.brown.edu . Archived from the original on 2016-10-18 . Retrieved 2016-10-09 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1475967600.0
  3. ^ "Crossing State Lines: Adapting Object-Oriented Frameworks to Functional Reactive Languages" . cs.brown.edu . Archived from the original on 2016-10-09 . Retrieved 2016-10-09 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1475967600.0
  4. ^ Burchett, Kimberley; Cooper, Gregory H.; Krishnamurthi, Shriram (2007). "Lowering: a static optimization technique for transparent functional reactivity". Proceedings of the 2007 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation (PDF) . pp. 71– 80. Archived (PDF) from the original on 2016-04-16 . Retrieved 2014-09-08 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1410130800.0
  5. ^ Bainomugisha, Engineer; Carreton, Andoni Lombide; Van Cutsem, Tom; Mostinckx, Stijn; De Meuter, Wolfgang (2013). A survey on reactive programming (Report). Association for Computing Machinery (ACM) . Retrieved 2026-05-17 . Also has taxonomy of extant reactive programming approaches. Wikipedia revision 1374071317, retrieved 2026-11-18 · 1778972400.0
  6. ^ Boussinot, Frederic (26 March 2007). "Reactive Programming: MIMOSA Project of INRIA – ENSMP" . French Institute for Research in Computer Science and Automation (INRIA) . Retrieved 2026-05-17 . General website on reactive programming, especially see the " general description ". Wikipedia revision 1374071317, retrieved 2026-11-18 · 1778972400.0
  7. ^ Roestenburg, Raymond; Bakker, Rob; Williams, Rob (2016). "13: Streaming". Akka in Action . Greenwich, Connecticut, USA: Manning Publications Co. p. 281. ISBN 978-1-61729-101-2 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1794956400.0
  8. ^ Demetrescu, Camil; Finocchi, Irene; Ribichini, Andrea (22 October 2011). "Reactive Imperative Programming with Dataflow Constraints". Proceedings of the 2011 ACM international conference on Object-oriented programming systems languages and applications . Oopsla '11. pp. 407– 26. arXiv : 1104.2293 . doi : 10.1145/2048066.2048100 . ISBN 9781450309400 . S2CID 7285961 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1794956400.0
  9. ^ Joosten, Stef (2018). "Relation Algebra as programming language using the Ampersand compiler" . Journal of Logical and Algebraic Methods in Programming . 100 : 113– 29. doi : 10.1016/j.jlamp.2018.04.002 . S2CID 52932824 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1794956400.0
  10. ^ Trellis Tele community. Model-view-controller and the observer pattern (Report). PEAK: Python Enterprise Application Kit. Archived from the original on 2016-03-03 . Retrieved 2009-07-27 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1248649200.0
  11. ^ Van den Vonder, Sam; Renaux, Thierry; Oeyen, Bjarno; De Koster, Joeri; De Meuter, Wolfgang (2020). "Tackling the Awkward Squad for Reactive Programming: The Actor-Reactor Model". Leibniz International Proceedings in Informatics (LIPIcs) . Vol. 166. pp. 19:1–19:29. doi : 10.4230/LIPIcs.ECOOP.2020.19 . ISBN 9783959771542 . S2CID 260445152 . Archived from the original on 2021-10-20 . Retrieved 2021-06-24 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1624489200.0
  12. ^ Van den Vonder, Sam; Renaux, Thierry; De Meuter, Wolfgang (14 June 2022). "Topology-Level Reactivity in Distributed Reactive Programs: Reactive Acquaintance Management using Flocks". The Art, Science, and Engineering of Programming (Report). Vol. 6. pp. 14:1–14:36. arXiv : 2202.09228 . doi : 10.22152/programming-journal.org/2022/6/14 . Archived from the original on 2023-03-15 . Retrieved 2023-03-16 . Wikipedia revision 1374071317, retrieved 2026-11-18 · 1678921200.0
source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"reactive programming". 1788966901. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1374071317

JSON record · API collection · citation policy