Reactive and Dataflow Programming
Streams of Values Over Time
The core idea is the stream (or observable): a sequence of values that arrive over time, such as mouse clicks, sensor readings, keystrokes or server messages. A program is a set of streams connected by transformations. You write what a result is, for example "the search box text, after the user pauses, without duplicates", instead of writing the timers and flags that produce it.
Operators and Pipelines
Streams are transformed with operators similar to those for lists: map, filter, merge, scan, and time-aware ones such as debounce and throttle. Because each operator returns a new stream, they compose into a pipeline. The same vocabulary appears in ReactiveX libraries for JavaScript, Java, C#, Swift and Kotlin.
Dataflow: Wires Instead of Statements
Dataflow programming draws the same idea as a graph. Nodes are operations and edges carry data, and a node runs as soon as all its inputs are ready. Order comes from the data dependencies, so independent branches can run in parallel automatically. Visual tools (LabVIEW, Simulink, Node-RED) show the graph, and textual systems (spreadsheets, build tools, signals in UI frameworks) build it implicitly.
Push, Pull and Backpressure
- Pull — a consumer asks for the next value, like iterating a list.
- Push — a producer sends values when ready, like an event. Reactive streams are push-based.
- Backpressure — when a producer is faster than its consumer, the stream must slow, buffer or drop values. Robust reactive systems make this explicit.
Representative Languages
These three show reactive ideas as a library, as a language architecture and as a visual language.
| Language | Why study it |
|---|---|
| RxJS (ReactiveX) | Observables and operators for asynchronous events in JavaScript, and the vocabulary shared by all ReactiveX libraries. |
| Elm | A pure functional language for the browser built around Model-View-Update and one-way data flow. |
| LabVIEW | Visual dataflow: programs are diagrams of nodes and wires, with parallelism for free. |