Spiegato, Home

Technology and Gadgets

What Is Reactive Programming?

  • Published by Spiegato
  • 2 min read

Reactive programming is a computer science concept that describes the properties of a computer programming language focused on automatically maintaining the state of an application as the data used in the program change. One of the main features of a reactive programming language is that declared and calculated variables are constantly re-evaluated as other variables used in their calculation change. This means the language reacts to the changes in the state of the data, as opposed to using more imperative commands to manage the state, the way many traditional programming languages do. The theoretical result of an application employing reactive programming philosophies would be a program that constantly and automatically changes the display or other factors based on the changing data that is flowing into the program. Although several imperative programming models can be used to achieve the same results as reactive programming, the goal of creating a reactive language would be to have native support for reactive changes at the primitive level, instead of at an object level.

One way to help clarify how reactive programming works is to compare it to imperative programming. When two numbers are added in an imperative language, the result of the addition usually is stored in a given memory location. The operation takes place the moment the command is executed, and the result is decoupled from the two numbers that were added to create the sum. This means that, if either of the two numbers that were added change after the addition takes place, the value of the sum would not change because it already is stored in memory and separate from the original operands.

When a reactive programming language adds two variables to create a sum and one of the two variables changes at some point in the future, then the sum also will change. This implies that a reactive program has the ability to monitor the state of the data being used and to react automatically to changes, potentially changing the overall state of the entire application. There are several models in imperative programming, including event-based programming and observer data models, that can perform the same tasks by creating structures that monitor data changes, but a reactive language would have built-in mechanisms to do this.

The use for a reactive programming language could be in areas in which real-time interpretation of arbitrary data streams is needed. This could include scientific visualization, graphical user interfaces (GUIs), or even real-time communications in which the program is constantly changing based on the data stream being received. It should be noted, however, that there really are no fully implemented, independent reactive programming languages. Most working implementations of the concept take the form of external libraries for more traditional imperative or functional languages.

Key terms in this article

Related articles

  • What is Distributed Programming?

    Distributed programming is one form of parallel programming or parallel computing. Parallel programming involves computers and computing units within…

  • What is ActiveX Programming?

    ActiveX programming is a framework developed by American computer software company Microsoft. This framework allows ActiveX modules, scripts and programs…

  • What Is Genetic Programming?

    Genetic programming is the process of using one computer program to write another computer program using evolutionary algorithm-based methodology. This…

  • What Is Flow-Based Programming?

    Flow-based programming is a method of designing computer applications and architectures that is unlike traditional structured methods of application…

  • What is ASP Programming?

    Active Server Pages (ASP) programming is writing code to facilitate ASP functionality on websites. Such functionality includes the delivery of dynamic…