10

I am reading Concepts, Techniques, and Models of Computer Programming and came across Flow-based (FBP) and Reactive programming paradigms. Now I have found the following article from J. Paul Morrison, the person who invented FBP. (Update 2025: that link is dead, but here is an overview.) I am also some what familiar with Reactive programming. But I am having hard time to differentiate this two paradigms. Both belong to Declarative and also under Dataflow paradigm. But what really sets them apart? I would like a concise answer with greatest distinction between these two approaches outlined.

reinierpost
  • 6,294
  • 1
  • 24
  • 40
Jernej Jerin
  • 225
  • 1
  • 5

2 Answers2

1

The best distinction I've found (which also makes sense) is in this quote from @chipsy from HN (brackets and emphasis mine):

FRP [Functional Reactive Programming] is very similar in nature to FBP [Flow-Based Programming]. (even the acronyms are similar) The main difference is in packaging.

The original FBP systems were still 70s-style near-metal code within the component design, but the architecture described a protocol just sufficient for statically and asynchronously connecting the components together, and a runtime method that is amenable to the simplistic approach of having each component run round-robin until all return a "finished" signal. It's very much an "industrial engineering" perspective.

FRP, on the other hand, comes from the traditions of functional programming, and so the evaluation order computation is given a more academic treatment, and the languages are given more explicit syntax, where FBP doesn't aim to describe itself much more deeply than the flowcharts. Both FRP and FBP have purity and immutability as core concepts.

So as I see it: different starting point, different packaging, same conclusions.

Source: https://news.ycombinator.com/item?id=6267892

"Functional reactive programming (FRP) is a programming paradigm for reactive programming (asynchronous dataflow programming) using the building blocks of functional programming (e.g. map, reduce, filter)." wikipedia

Also, for reference, the definitions:

  • "FBP is a particular form of dataflow programming based on bounded buffers, information packets with defined lifetimes, named ports, and separate definition of connections." wikipedia

  • "In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change." wikipedia

My current understanding:

Flow-Based Programming approaches seems more concerned with architecting an application based on data processing pipelines, especially oriented towards processing large data sets (think distributed MapReduce):

NoFlo is a JavaScript implementation of Flow-Based Programming (FBP). Separating the control flow of software from the actual software logic. Helping you organize large applications easier than traditional OOP paradigms, especially when importing and modifying large data sets.

With NoFlo, your application consists of independent components that are connected together in a graph. This makes it possible to split your problem in logical areas that make sense, and to see how they connect with each other.

The MIT-licensed NoFlo library can either be used to run full flow-based applications or as a library for making complex workflows or asynchronous processes more manageable. It can also be used as an Extract, Transform, Load (ETL) tool in business applications.

Source: https://noflojs.org/

FBP is a special case of dataflow programming characterized by asynchronous, concurrent processes "under the covers", Information Packets with defined lifetimes, named ports, "bounded buffer" connections, and definition of connections external to the components ...

Source: https://jpaulm.github.io/fbp/index.html

Useful references used here, and for further reading:

Magne
  • 126
  • 4
0

I think there are some clear conceptual differences between FBP and FRP. I will go by the descriptions of these paradigms given by J Paul Morrison and Stephen Blackheath & Anthony Jones respectively.


In FBP, nodes are homogeneous, as are edges. Each node in the graph represents a pure function. There are some incoming edges which carry the function's arguments, and an outgoing edge which carries the function's result (or multiple outgoing edges, carrying copies of it).

Data only flows along the edges between nodes, it is not stored in the nodes. The graph has no mutable state, it describes a pure computation from the network's overall input(s) to the network's overall output(s). Assuming the graph is connected, data flows along every edge of the graph when the computation is evaluated, so each node always receives all of its inputs (at least conceptually; option types can still be used to represent absent values).


In FRP, nodes are heterogeneous: some are cells, others are streams.

A cell holds a value, which can change over time. There are several kinds of cell, each of which defines a different rule for how and when the cell's value changes. For instance, a "hold" cell has one incoming edge, which must come from a stream, and the cell's value is the most recent value sent from that stream.

A stream holds no state, but it doesn't necessarily output any data even when it receives some. There are several kinds of stream, with different rules for when and what values they send on their outgoing edges. For instance, a "filter" stream has one incoming edge, which must come from another stream, and it sends out the same value it receives, but only if that value satisfies some predicate.

A program run generally consists of multiple transactions, with program state persisting between them; for instance, a "hold" cell persists the value from a stream several transactions ago, if that stream didn't send any new value since then. Moreover, even when the graph is connected, data need not flow along every edge during one transaction (at least conceptually; an actual implementation might use option types to represent data either flowing or not).

Perhaps the greatest conceptual difference, though, is that an FRP program can change its own graph at runtime. Cells and streams are values, which can be constructed and returned from pure functions, and themselves held in other cells or transmitted along other streams. For instance, when a cell holds another cell, it can be "flattened" into a new cell whose value is the value held by the nested cell. When a cell holds a stream, it can be "flattened" into a new stream which sends the value sent by the nested stream.

kaya3
  • 520
  • 2
  • 10