Reactive programming is a programming paradigm focused on data flows and the spread of change. This means that there should be the ability to easily express static and dynamic data streams, and also that the underlying execution model should automatically propagate changes due to the data stream.
For example, in imperative programming, assigning a = b + c will mean that the variable a will be assigned the result of the operation b + c , using the current (at the time of calculation) values of the variables. Later, the values of the variables b and c can be changed without any effect on the value of the variable a .
In reactive programming, the value of a will be automatically recalculated based on the new values.
Modern table processors are an example of reactive programming. Table cells can contain string values or a formula of the form “= B1 + C1”, the value of which will be calculated based on the values of the corresponding cells. When the value of one of the dependent cells is changed, the value of this cell will be automatically updated.
Another example is hardware description languages (HDL), such as Verilog . Reactive programming allows you to model changes in the form of their distribution within the model.
Reactive programming was proposed as a way to easily create user interfaces, animations, or simulate systems that change over time.
For example, in the MVC architecture, using reactive programming, you can automatically reflect changes from Model to View and vice versa from View to Model.
Content
Concepts
Reactive programming approaches
Imperative Reactive Programming
You can combine the paradigms of reactive and imperative programming. In such a bundle, imperative programs could work on reactive data structures.
Object Oriented Reactive Programming
Object Oriented Reactive Programming (OORP) is a combination of an object oriented approach with a reactive one. Probably the most natural way to do this is that instead of methods and fields, objects have reactions that automatically recalculate values, and other reactions depend on changes in these values.
Functional reactive programming
Functional programming is the most natural basis for implementing reactive architecture, combining well with concurrency .
Functional reactive programming (FRP) was formed in 1997, with the proposal of the Fran language [1] . Later, languages such as Fruit, FRP and RT-FRP, FAL, Frob, Fvision, Yampa were developed [2] .
The simplest functional reactive expression has the following form [3] :
b1 ` until` e => b2
which literally means " behave like b1 until event e occurs, then behave like b2 ."
Implementations
- - Facebook -created JavaScript library for user interface development
- Elm is a functional reactive programming language compiled in HTML , CSS and JavaScript
- - an event-reactive language for programming web applications
- ReactiveX is a multi-platform implementation of reactive programming for Java , JS , C # , Scala , Clojure , Swift , etc.
- Reactive.jl - FRP implementation for Julia
Links
- ↑ Functional Reactive Animation
- ↑ Mun Hon Cheong. Functional Programming and 3D Games . - The University of New South Wales, 2005.
- ↑ Paul Hudak. Modular Domain Specification with Languages and Tools . - IEEE Computer Society Press, Department of Computer Science, Yale University, 1998. Archived October 17, 2013.