Yeah. More power to people like this who are trying to make pure-functionalism more accessible and practical, but I have my doubts that contorting logic that's naturally stateful into a denotational paradigm will ever feel natural or intuitive. Human intuition is rooted in navigating the physical world, and imperative/cause-and-effect thinking is a very physical way of accomplishing things.
Thinking about things like this is really tiring, but I suspect I get less bugs when I do.
Re:The Misunderstood Roots of FRP
by throwaway_n on Sunday November 03, 2019 @01:30AM
(#21432522)
Won't your example trigger an infinite loop of celsius/fahrenheit conversions? Especially if the floating point value is slightly off.
I think your example is exactly why stuff like React won vs data-binding frameworks. With declarative programming, you just have a single source of truth that you change once (you can arbitrarily pick celsius or fahrenheit or even kelvin) and let the framework figure out what needs to be diff-ed in the derived views.
I'm not aware of any actual real-world GUI system where ".whenChanged do" is valid syntax, but just for the sake of argument, pretend that it only fires when the user changes the textbox. Coincidentally, this also happens to be how the "change" event works in JavaScript.
I know of one that's essentially like that [0], but like you suggested - it only fires on user action, not programmatic update.
(The examples here are for buttons and sliders, but it's the same syntax for input fields)
When working on GUIs that used callbacks like this, I’d have a method for setting the value of the second component which didn’t raise a ’changed’ event, or I’d turn off raising events for the second component before telling it to change then tell it to continue.
They weren’t beautiful, but both methods worked fine for the rare cases they proved necessary.
I think this is true of a lot of UI programming: most people intuitively think about it in terms of "when X happens, do Y", so trying to cram it into another programming model is more trouble than it's worth.