What is Reactive Programming?

36

Can anyone explain me clearly and objectively?

I have read a few more articles but it was not very clear.

    
asked by anonymous 22.03.2015 / 15:32

1 answer

53

Reactive programming is programming with asynchronous data streams. Asynchronous means that it does not happen at the same time or at the same rate of development (relative to something else).

This is important because of the growth of the Internet and the demand for real time, programming needs to be dynamic, that is; different from the traditional form of development.

The traditional way of programming / developing, for example, creates multiple tasks and they communicate at specified times, with determined answers without scalability in case of failure, some greater demand, are "rigid", follow direct rules. This worked and continues to be used until today, however this "logic" is no longer compatible with the current need.

In the traditional method is how to prepare the cement mix, after it has sent the data saying that it is prepared, is called the function of building the wall, then the plaster, wait a set time, past the period is called the function to paint and if you miss the painter? It screwed everything up, it made the system error! Or if communication fails? Error too, system crashes, you usually have to redo everything!

In reactive programming, everything happens, but intelligently, interconnected in parallel, without following the chronological and linear order, for example: the wall is built, the plaster is missing, the time to dry, then the paint. It has no painter, fails in this task, the system will not lock, recognizes that it is possible to continue other parts of the construction in parallel like the floor, to lay the floor, while waiting to paint, without having to start all over again, to finish painting afterwards, without having been interrupted by the "error".

That's the logic, it seems kind of obvious if you think about it, but the systems are still not very intelligent, they need to be properly programmed to be able to manage failures, different routines, follow alternative paths, many accesses, always be online / active!

The pillars of reactive programming follow:

  • Elastic : Reacts to demand / load: applications can make use of multiple cores and multiple servers;
  • Resilient : Reacts to faults; applications react and recover from
    software, hardware and connectivity flaws;
  • Message Driven: Responds to events ( event driven ): instead of composing applications by multiple threads synchronous, systems are composed of asynchronous and non-blocking event handlers;
  • Responsive : React to users: applications that provide interactive rich and "real-time" users.

More details can be found in this video and this article .

    
23.03.2015 / 00:19