A full-blown tutorial on DIY <functional reactive ...
# linking-together
j
A full-blown tutorial on DIY functional reactive programming, from one of the Spritely folks. Also collects relevant PL dissertations on dataflow, e.g. FrTime and propagators, as well as explorables like Holograph.
c
This is a great article. i'm a big Hoot fan I'm surprised the article doesn't mention SolidJS! solid's responsible for popularizing Signals again in JavaScript. Its fine-grained/narrow updates to specific ui nodes are powered by the reactive graph. no vdom, components don't rerun. i think he might like it!
also i'd never seen the linked Holograph before, that's so sick i love it ! !
b
this is excellent -- thanks for the link.
k
@Dennis Hansen ^^ praise for your Holograph.
d
Ayy thanks you @chee ! Love to see the propagator love
k
I love the metaprogramming aspects of Holograph, i.e. accessing and setting properties of the visual elements!
Does the first example (temperature converter) work for others? For me (Firefox, macOS), when I change the "Celsius" value, it goes into an endless update loop. Which is not that surprising, given that the graph has cycles. Strangely enough, updating the Fahrenheit value leads to a one-sweep stable update.
d
Curious which value you put in for Celsius that makes it loop? I can try to reproduce it. In any case, propagators only fire when cells have changed- that's what allows networks to reach a stable states despite having loops.
k
@Dennis Hansen Here is what I did: 1. Open https://www.holograph.so/ 2. Replace "100" by "50" in the "Celsius" circle. Here is what happens:
d
hm, shouldn't oscillate like that- might be a firefox thing- haven't tried it on that i'll have to investigate. Thank you!
k
Working for me on Windows Firefox.
k
@Dennis Hansen Something I wonder about: you say "propagators only fire when cells have changed." In the temperature converter, you have division in the cycle, which is inexact unless you use rational numbers (which JS doesn't have). So the cycle could propagate change forever. That's probably not what is happening here, as the oscillating values differ too much to be amplified round-off, but I wonder how you deal with numerical issues in general.
d
Yep good observation @Konrad Hinsen- I haven’t run into major issues with precision so haven’t solved it yet but but as it becomes problematic i suspect I can utilize fractions-based data structures or employ heuristics to stop oscillations as needed. Not too sure yet.