Hacker News new | ask | show | jobs
by diminish 4055 days ago
Question for experts: why Browsers do not get the idea of updating changes the way react does automatically possibly with a start, stop transaction or better without.
2 comments

It would be wonderful if browsers acted more like game engines. Collect user input and at the beginning of every rendering "frame", allow JavaScript to process the input and modify a virtual DOM. Then, render the virtual DOM. It would be so much easier to reason about web applications this way.
I'm messing around with ideas for an experimental hypertext engine, now you've got me tempted to try building it on a game engine. Looks like Unity might have halfway-decent text support.
Whenever a change is made to the raw DOM, the change has to be immediately visible to the code running after it. React sacrifices this.

When the DOM is treated as the source-of-truth for the page's information, the synchronously-visible changes are very useful. However, getting away from treating the DOM as the source-of-truth, which React forces you to do, gets you a lot of power as changes to the DOM can be batched more efficiently automatically.