Reactive Programming Without Functions
programming-journal.org
programming-journal.org
Push often leads to wasted computations via updated values that don't end up getting used downstream either due to later updates affecting the same downstream nodes or simply because a value isn't being actively observed. Batching changes to signals can avoid the first cause (and it seems their execution model is implicitly batched by default?), but it doesn't solve the second.
Push-Pull systems (which don't seem to be mentioned) solve this by pushing invalidation of signals down the graph, then on pull any signal that is invalid gets recomputed. Handling cycles in the reactive graph is also easier with this approach, rather than getting stuck in an infinite update loop, if something is invalidated it's consumers do not need to be invalidated again.
I think the effort of creating RP languages is definitely a worth-while endeavor, but I'm not sure that they should have no imperative code, as seen with the recursive example taking things to the imperative or functional code level can have benefits. It would be interesting to see a language that is by default reactive, but has an escape hatch for imperative/functional logic.
It's like saying that a free monad represents a computation but doesn't actually execute it.
The user can read the context and execute computations and side effects.
From a DX point of view it can enable some good applications but it just shifts "where" the computation will run. The developer will still think in terms of functions.
(I also love Perl, so I'm not the most consistent person, but I love it most for its focus on text handling, so I'm not the most inconsistent person either.)
Imperative languages that have bolted on functional features, e.g., don't give you the guarantees (constraints) that FP languages can offer. And of course in OO languages state is everywhere.
I like this feature quite a bit:
> We propose a different approach that makes mutable state an explicit part of the language model. In Haai, deployments are able to accumulate state by means of so-called trampoline variables — or trampolines for short. They provide programmers with a general notion of state in the RP model. In essence, a trampoline is a variable, local to each deployment, that is updated after each turn.
Why would you want that? The paper is pretty readable, but it's (1) interesting theoretically and (2) it solves a lot of failure modes in reactive programs, such as deadlocking a single execution thread, never yielding back to the scheduler, ....
Correct or not?
* Defines recursion as either lifted (functional) recursion or graph recursion
* Forbids lifted/functional recursion as it might diverge (Graph recursion still allowed)
* Graph recursion might diverge