Reactive programming: what is it?

Reactive programming is implemented more and more frequently in the corporate world. It is a programming paradigm based on the transmission of data from a single source or from several sources. The concept is not always clearly understood, and its importance is underestimated. This is what reactive programming is all about.

programming-screens-1300px (1)

The observational design patterns

Reactive programming was created from the observer design pattern whose defects needed to be corrected. The observing pattern is one of the behavioral patterns developed from the Gang of Four's now authoritative book Design Patterns- Elements of Reusable Object-Oriented Software.  


Experts use this design pattern for state machine design. A state machine is a dynamic system that operates in cycles. In this system, an external event creates a transition from the current state to another state. The machine can only be in one state at a time. The order in which the transitions occur is defined within a state register.


The variables in which the data is stored must be visible to any observer. This results in a code that is not sufficiently composable. An approach has been developed to implement reactive applications to separate event producers and event consumers. It is thus a question of separating the observable from the observer.

An increasingly necessary programming

Reactive programming is increasingly being used within companies. Most modern applications are reactive, i.e. they respond to events that come to them and react to them with calculations. Users thus improve their relationship with the system and interact better with it. Better answers can be obtained more quickly.


Reactive programming is based on the transmission of data from one or more sources. All data without exception is processed through a stream. The stream represents data that arrives in an orderly fashion. The stream emits three types of signals. It emits a value, but also an error. Finally, it emits the signal indicating that there is no more data to send.

Companies and organizations implement this type of reactivity at all levels. It is particularly found in graphical user interfaces. Modern applications have several indispensable qualities. Their high availability is appreciated. Indeed, they respond quickly to any event.

Reactive applications are also increasingly resilient as they develop. The system remains available, even when an error occurs. Even if it is overloaded, the system is not destroyed. Reactive programming therefore meets most modern requirements.

Correct expressions

In reactive programming, each of the variables is initialized when the expressions are analyzed. Each dependency between the variables is recorded. When one of these variables is affected by an event, i.e. when it undergoes an update, the other variables that depend on it also undergo an update. From each update, other updates can be triggered with other variables to which they are linked.


Reactive programming proceeds in such a way that each expression is correct at all times.

Reactive programming concepts

In order to understand how reactive programming works, it is necessary to know the main concepts to which it refers.


In reactive programming, it is often a question of variations in values over time. By this concept, we mean that at any point in the execution of the program, every expression in the program must remain correct. The values of the variables change over time as the program runs.


Another important concept in reactive programming is event flow. This is the concept that when a variable changes its value, the variables that depend on it also undergo an update. An event/message is then set up. All events that may occur must be taken into account in this type of programming.


Dependency monitoring is also part of the concepts used in reactive programming. All dependencies between variables, whether direct or indirect, must be monitored. A new dependency may appear. It must then be saved. Later, it can propagate value updates.


As for the concept of automatic propagation of change, it means that when a variable is updated, all the other dependent variables are informed, and also undergo an update. The propagation of updates must continue automatically so that all the variables are thus updated, whether they are directly or indirectly dependent.


Benefits and disadvantages


Reactive programming is increasingly used for its many advantages. In particular, it helps to avoid malfunction, since they are caused by a design problem, they can no longer occur because a variable has not been updated. The time that is saved at runtime is considerable and allows you to concentrate on other tasks.


Moreover, in terms of applications, many of them are much easier to write in reactive programming. The work is therefore simplified. The programmer also doesn't have to worry about the order in which events are triggered.



Programmers note, however, that there is still room for improvement in reactive programming. For the moment, it remains difficult to implement. In addition, since this type of programming is asynchronous, the flows can be difficult to follow and it is not always easy to understand them. The compiler is also difficult to decipher. Reactive programming will therefore need to correct these problems in the future.

The compiler presents a major difficulty. For each variable, a list of the variables that depend on it must be assigned. The dependencies must therefore be searched for and new calculations must be performed for the change that the variable has undergone.

Reactive programming languages

Reactive programming languages are classified as control flow-oriented languages. Among these languages are RxJava, RxJS, Rx.Net, RxScala and RxSwift.


RxJS, for example, is the JavaScript implementation of ReactiveX, a project that aims to put in place the necessary tools to make the reactive paradigm available in several languages. These tools come in the form of a library.


ReactiveX offers a data flow based on the observable and the observer. The observable is the source of data emission itself. It emits data as soon as an suscriber is listening. The emission of data ends with a signal indicating success or an error in the emission. As for the suscriber, or observer, it is he who listens to the observable and retrieves the data transmission.


ReactiveX provides a list of operators. They allow the data flow to be considerably refined. With the help of these operators, it becomes possible, among other things, to chain actions one after the other and to filter the results according to different conditions. Among the main operators are Map and flatMap. Both have proven their worth.


If you want to make the best use of your data, please contact Ryax!

La Ryax Team.