Functional Reactive Programming
nexocode.com
nexocode.com
Let's keep "FRP" for what it really stands for in honor of it's inventor (http://conal.net/talks/). Rx is not FRP and was explicitly designed as a discrete collection API on purpose (as opposed to continuous time varying values). ...
[1] https://github.com/ReactiveX/reactivex.github.io/issues/130
Sigh.
well, dataflow programming has always been central to reactive programming, isn't it ? that's what all reactive languages, Esterel, Lustre, etc. were about.
"Reactive" is really just a re-branding of (synchronous) dataflow programming, and a fairly bad one at that because it just jumbles up and confuses so many things.
"Reactive" is/was really a type of system: one where you have continuous interaction with the outside world and the world generally cannot wait (similar but not identical to real-time). Contrasting with "transformational", where you just get some inputs turn them into outputs and are done, and "interactive", where you interact with the outside world but the world can wait.
It turned out that the synchronous dataflow languages (like Esterel, which is imperative, and Lustre, which is functional) had some fairly nice properties when it came to building reactive systems. As far as I know, Esterel is used for Airbus avionics...so the outside world really, really cannot wait :-)
How people somehow managed to mix up the style of system with the technology and then somehow also put in a claim that "functional" was an essential part of it is a little beyond me.
are about.
If actual FRP for web wasn't doing so relatively well, I would begin to fear that FRP is heading the same way OOP did after Smalltalk, a shadow of the actual thing pushed as a buzzword to sell to marketing managers with no clue or concern about the actual tech.
And god help me, I do not want to see what the C++ of FRP looks like ...
plenty of reactive libs in there. The original one was Qt with the signal system. More recent research in this domain is for instance RaftLib : https://github.com/RaftLib/RaftLib/blob/master/examples/gene...
Though I grant you that C++ could just as easily wind up filling both blanks.
edit: spelling mistake
As Elliott himself suggested [0], it might be a good idea to use the term DCTP when talking about the concept you're talking about. Yes, it might feel wrong because his FRP was "first", but at least it's clear.
> To reduce confusion, I would like to see the term “functional reactive programming” replaced by the more accurate & descriptive “denotative, continuous-time programming” (DCTP)
[0] http://stackoverflow.com/questions/5875929/specification-for...
My job is to write actual FRP so it's no sweat for me to vigorously complain every time that people are stealing "my" term :p
While Conal may have distanced himself from FRP, in the Haskell FRP community that's what we still call it.
I was wondering whether it is possible to achieve the same effect without client side JS, perhaps with HTTP2 push?
Arbitrary side-effects coupled with asynchronicity are a recipe for Heisenbugs.
Additionally, if you add in the constraint that you can't change signal routing at runtime and you only use pure functions on stream, you can actually debug by moving streams to any point in their history and figuring out what the system is doing with them. That's a very common debugging technique in the Elm programming language, for instance, as shown here: https://www.youtube.com/watch?v=RUeLd7T7Xi4.
I find it easy to avoid side-effects in imperative reactive code. With side-effects I wouldn't call it reactive.
> , if you add in the constraint that you can't change signal routing at runtime
Once again, this is easy in imperative code.
I am not complaining about functional code. It definitely has its place (just not for me). I just finished an awesome product with imperative reactive code and I thought maybe I was missing something.
In fact, what "reactive programming" does is solve the problem that FP has with reactive systems[1], in that it isn't suited for them at all. FP, pretty much by definition, is suitable for transformational systems, i.e. systems that map some inputs to some outputs and are then done.
With just FP, there really isn't any way to build reactive systems, that is systems that continuously react to external and internal stimuli, whereas reacting (responding) to stimuli (messages) is pretty much the definition of OO.
By treating input as (infinite) streams of data and applying collection processing to those, you can sort of map this to the aforementioned dataflow programming and solve your problem. Of course, just using dataflow programming directly is both simpler and faster, but hey...
[1] https://www.inf.ed.ac.uk/teaching/courses/seoc/2005_2006/res...
But a good reactive system is simpler to write, understand, and debug. At least that is what I found in my latest project.
Because what you write certainly sounds a lot like just dataflow.
To me, dataflow is simply a stream of data triggering calculations even if the data is unchanged. e.g. the stream of 1,2,2,3 would cause four calculations.
Reactive means that only 1,2,3 would appear to the calculations. In other word only changes are reacted to.
My framework is reactive by these definitions.
The result is that you can do the same things with a Behavior as you can with other Functors and Applicatives and things - for example you can `map` it with a function that operates on that inner value (whatever it may be) and you'll get a new Behavior which contains that transformed inner value.
> There is an internal joke in the team that React should have been called “Schedule” because React does not want to be fully “reactive”.
(from [0])
You could look at a React+Redux application as a somewhat limited reactive architecture though: [1] (from [2]).
[0] https://reactjs.org/docs/design-principles.html
[1] https://vincenttunru.com/assets/img/Javascript-reactive-prog...
[2] https://vincenttunru.com/Javascript-reactive-programming/