
Functional Reactive Programming - niutech
https://www.nexocode.com/blog/posts/reactive-programming/
======
danharaj
None of this is _functional_ reactive programming as originally formulated by
Conal Elliott and Paul Hudak, which in particular emphasized the need to model
reactive programs as the algebraic composition of simple _abstract_ units,
events and behaviors. If you have to set up a listener for an event, you
aren't doing FRP, you're just doing Reactive Programming.

~~~
Vinnl
This same discussion comes up every time FRP is mentioned, because most
articles that say they are about FRP are about Reactive Programming using
Functional methods. You can keep bring it up every time you see such a post,
but maybe it's better for your own sanity to just realise that ship has
sailed: when people write about FRP, they write about this.

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...](http://stackoverflow.com/questions/5875929/specification-for-a-
functional-reactive-programming-language/5878525#5878525)

~~~
danharaj
This same discussion comes up every time FRP is mentioned, because most
articles that say they are about FRP are about Reactive Programming using
Functional methods. You can keep bring it up every time you see such a post,
but maybe it's better for your own sanity to just realise that ship has
sailed: when people write about FRP, they write about this.

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.

~~~
Vinnl
Haha, well, if it's no effort for you to keep it up, then by all means, keep
it up :) Just don't expect it to actually change :P

------
a_imho
_To achieve such effect as presented above you need to use Server-Sent Events
(SSE)_

I was wondering whether it is possible to achieve the same effect without
client side JS, perhaps with HTTP2 push?

------
mchahn
Can someone explain the synergy of using reactive with functional? Reactive is
great and functional is great but I don't see what they have to do with each
other.

~~~
mpweiher
You are correct, there isn't really any synergy, and it's just a re-framing of
synchronous dataflow programming using somewhat convoluted terminology and
technology.

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...](https://www.inf.ed.ac.uk/teaching/courses/seoc/2005_2006/resources/statecharts.pdf)

~~~
mchahn
> just using dataflow programming directly is both simpler and faster,

But a good reactive system is simpler to write, understand, and debug. At
least that is what I found in my latest project.

~~~
mpweiher
What dataflow system/language did you use to compare?

~~~
mchahn
The framework is custom. But I was really talking about how great reactive was
for my application. It is a control system with a lot of inputs and outputs.
The graph is about a dozen levels deep.

~~~
mpweiher
So you weren't actually comparing reactive with dataflow?

Because what you write certainly sounds a lot like just dataflow.

~~~
mchahn
I can't answer this without knowing your definition of reactive.

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.

------
sebringj
In practice, I've used socket.io and redis to glue dbs and apis and queues and
schedulers and clients together and the clients listen to sockets for data
payloads to modify the views. View interaction sends event payloads to modify
the various systems which kick off further data payloads. That is the entire
concept. No article was necessary in the making of this post.

------
baron816
Does anyone know if React got its name from React Programming?

~~~
baron816
Why was this downvoted? React essentially uses observables, right? Child
components don’t directly listen to changes in the state objects of their
parents. Instead, parents know how to update their children when setState is
called. Thus, the inversion of dependencies decouples objects in React in the
same way observers are decoupled from their subjects in RxJS. Redux has a
dependency on RXJS for a reason.

~~~
reaktivo
Redux doesn’t have a dependency on RxJS. It does expose and observable
interface though

