3 ms·
input = 1 out1: input + 1 #out1 is now 2 input = 4 #out1 is now 5 out2: out1.replace(+, -) #out2 is now 3 # let's pull an APL input = 4 2
by eatonphil 4y ago
input = 1
out1: input + 1
#out1 is now 2
input = 4
#out1 is now 5
out2: out1.replace(+, -)
#out2 is now 3
# let's pull an APL
input = 4 2
#out1 is 5 3
#out2 is 3 1
The reactive programming idea a la Excel but text-based looks really neat. I'd love to play around with that kind of thing.
- arethuza 4y agoI have a vague recollection that the language used by MS PowerApps might work like that: https://docs.microsoft.com/en-us/power-platform/power-fx/overview https://docs.microsoft.com/en-us/power-platform/power-fx/ove...
- shreyshnaccount 4y agodoesn't interactive Julia (that's what it's called?) do this? i remember seeing an example but i might be misremembering things
- francogt 4y agoPluto.jl[1] works like this. It’s a reactive notebook. It’s a really neat project. [1]https://github.com/fonsp/Pluto.jl https://github.com/fonsp/Pluto.jl
- shreyshnaccount 4y agoAh yes, that's what I was thinking about. thanks! its so cool xD
- sdfhdhjdw3 4y agoYes. And Julia also does the "optimized version of...". It dispatches on types.
- kej 4y agoI haven't used it beyond playing with the tutorial, so I don't know how well it works in practice, but Svelte does this with JavaScript: https://svelte.dev/tutorial/reactive-declarations https://svelte.dev/tutorial/reactive-declarations
- nathancahill 4y agoI've been using Svelte in production for ~3 years now. Hard to go back once you get used to reactive programming.
- hota_mazi 4y agoThis looks like hell to me. It's side effects to the tenth power, which must make debugging an absolute nightmare.
- mlajtos 4y agoNot really – you won't get into an inconsistent state when everything is reactive. One thing that might lead to catastrophe is having cyclic dependencies, but reasonable runtime/compiler can detect those.
- hota_mazi 4y ago> you won't get into an inconsistent state when everything is reactive That's like saying "There will never be bugs". There will be bugs. And when you come across one and you can change a variable and have another variable affected in some other part of your program and you have no idea how these two variables are connected, you are going to have a nightmare of a time debugging.
- cmontella 4y agoYou would only have no idea those variables are connected if the tooling for the language can't help you figure that out. Ideally, in such a language you could just query the program state to determine everything that would be influenced downstream. Also step-by-step execution and record/replay or program state can help debug those tricky issues. New paradigms of programming call for new paradigms of tooling and debugging, and figuring out what those are is part of the fun!
- mlajtos 4y agoOf course there will be bugs. But they won't be caused by the system NOT updating the variable when it should be. But it is still up to the programmer to create a valid reactive graph. > you have no idea how these two variables are connected Simply traverse the reactive graph to reveal how/if two variables affect each other. Cycles and dynamically changing bindings are still problems, but they can be tackled.
- 4y ago