4 ms·
This is an interesting article, but I don't think it gives enough credit to Functional Programming. The article presents functional programming applied to push
by doublerebel 9y ago
This is an interesting article, but I don't think it gives enough credit to Functional Programming. The article presents functional programming applied to push streams, which is part of FRP but only one way to look at Reactive Programming.
Thinking in streams is a great exercise but is not a panacea. It's really easy to get started with streams in a toy example, but in real world applications backpressure and buffering are a concern. The consideration of backpressure also opens the push/pull stream discussion. If you are interested in applying more from this article, the API is very similar in Godot2 (Node) [0], which is based on Riemann (Ruby) [1]. (Node streams have configurable backpressure/buffering [2].)
Complex interconnected events can cause a runaway snowball effect if not carefully constructed or bound by limits:
* Elm's "time-travel" debugger is so valuable because it allows introspection through an event chain that may not be linear.
* Node takes a common approach, which is to push data/events through the stream but handle errors by bubbling up the stream processing chain. This Node approach maintains a hierarchy that is relatively easy to reason about.
* React is popular because it effectively is FRP applied to the data model: the JSX view is the function, and the change in data model is the event. Since data model changes are limited, atomic, and one-way this makes React easier to reason about than other frameworks (Angular, I'm looking at you). This concept pre-dates React, I've used it since years ago with SpineJS and Knockout.
Last but not least, when using streams there is an important tradeoff between speed/latency and delivery/processing guarantees, which is enough for its own discussion...
[0]: https://github.com/nextorigin/godot2 https://github.com/nextorigin/godot2
[1]: http://riemann.io/concepts.html http://riemann.io/concepts.html
[2]: https://nodejs.org/en/docs/guides/backpressuring-in-streams/ https://nodejs.org/en/docs/guides/backpressuring-in-streams/
- platz 9y agowhen talking about 'backpressure' it is essential to distinguish whether we are talking about pull streams or push streams, and if the backpressure mechanism is in-band or out-of-band. usually when we talk about a 'reactive stream' we are only talking about push streams, because if you are truly reactionary the consumer doesn't control the flow like a pull-based iterator does.
- seanmcdirmid 9y agoMost of those aren't FRP, at least in the Elliott/Hudak sense. Or if you mean anything that pushes streams around is FRP, then of course that existed long before FRP was even a word and happens in non-functional paradigms as well.
- doublerebel 9y agoI agree. I intended to make it clear with my first sentence that Streams as described in the article is just a subset of Reactive Programming. My point is that Functional, Reactive, and Streams programming have common concepts that are important programming tools, when used appropriately. However, Reactive Programming is neither exclusively Functional nor Streams-based, although the article implies it.
- mpweiher 9y agoVoice of reason. Thank you! Synchronous dataflow, Lucid, Esterel, Supercollider :-) FP does not solve a problem for reactive programming, reactive programming solves a problem for FP.
- didibus 9y agoCorrection, Riemann is implemented in Clojure, not Ruby.