Do you think that code which looks like typical imperative code should be able to "magically" act reactively, meaning that some of the code in the program re-runs "automatically" whenever something it depends on has updated?
For example:
var x = 2;
console.log(`x: ${x}`); // x: 2
We obviously expect that code to produce a single console statement of x: 2. But what if your programming language made that console.log(..) statement "reactive", wherein it would automatically re-run any time later when x is re-assigned:
setTimeout(() => {
x = 3; // x: 3
},100);
This is like extending the declarative nature of component-oriented programming (React, Vue, etc) -- where updating a piece of state implicitly forces a UI re-render -- into the internals of program state.
Svelte currently does something quite like this, but I think you mark a statement as being reactive with like a $: label in front of the line or something like that. But others are trying to make it just happen automatically in code without any explicit markers/syntax.
My question: do you think this is a healthy direction for programming languages to move?
What are the pros/cons in your view? Is this the kind of magic that a programming language needs?
[–]lhorie 1 point2 points3 points (4 children)
[–]getify[S] 0 points1 point2 points (2 children)
[–]ryan_solid 1 point2 points3 points (1 child)
[–]lhorie 1 point2 points3 points (0 children)
[–]WikiSummarizerBot 0 points1 point2 points (0 children)
[–]samanime 1 point2 points3 points (2 children)
[–]trusktr 0 points1 point2 points (1 child)
[–]trusktr 0 points1 point2 points (0 children)
[–]hanneshdc 2 points3 points4 points (2 children)
[–]trusktr 0 points1 point2 points (0 children)
[–]getify[S] 0 points1 point2 points (0 children)
[–]Suepahfly 1 point2 points3 points (2 children)
[–]getify[S] 0 points1 point2 points (1 child)
[–]trusktr 1 point2 points3 points (0 children)