3 ms·
I like the proliferation of ideas around React and the various new attempts at cool stuff. Question, though: why is the idea of glorified two-way bindings with
by EGreg 11y ago
I like the proliferation of ideas around React and the various new attempts at cool stuff.
Question, though: why is the idea of glorified two-way bindings with dirty-checking constantly popping up? It may make your code slightly prettier, but at the expense of efficiency. Instead, what's wrong with this:
component.state.x = 5;
component.state.y = "blah";
component.stateChanged("x","y");
And in the view:
component.onStateChanged("x").set(function() {
component.someExactElement.innerHTML = x; // or whatever
});
No need to do dirty checking, and it's explicitly clear what the bindings do.
- Someone 11y agoBecause it automates away bookkeeping. Consider component.state.x = 5; component.state.y = "blah"; component.state.z = "bug!"; component.stateChanged("x","y"); That one line addition should have included a change to the last line. Also, I don't know whether it is done, but with a relatively slow/relatively large overhead network between the bound objects, software can bunch up the synchronization of changes to independent objects.
- pjmlp 11y agoAt least in JavaFX/XAML models you can do some clever bindings between components without writing a single line of code, besides the ones to create the components that is.
- cheez 11y agoQML (part of Qt) did this right. Unfortunately, it did a bunch of other shit wrong. In particular, if you could just apply the QML object model to the web, you'd get nicer code.
- coldtea 11y agoBecause we moved away from manual memory management. Why we'd we introduce even more basic manual variable change propagation?