I'm quoted in this blog post so I figured I'd respond. I'm a former member of the React team but I haven't worked on it in a long time. Largely I agree with everything in this article on a factual basis but I disagree on the framing of the trade-offs. Two points in particular: 1. Before open sourcing React we extensively measured performance on real world applications like mobile search and desktop ads management flo…
Virtual DOM is pure overhead (2018)
211–220 of 337 posts
Re: Virtual DOM is pure overhead (2018)
#212I can't trade TSX for any text templates. Being able to write tags and having them syntax-checked with types support is indispensable. I wish that those frameworks embrace TSX rather than trying to drag users to the dark past.
Re: Virtual DOM is pure overhead (2018)
#213If I see html in a javascript file, I boycott the codebase
Re: Virtual DOM is pure overhead (2018)
#214Earlier quoted context omitted.
In Sciter you do not need any preprocessor at all, not even JS in your HTML: div.beer { prototype: Beer url(/components/beer.js); } After that div.beer element will be instanceof Beer. In this case class Beer used as a [Web-alike] component.
1. I think you accidentally a tag 2. Your example would have atrocious load time implications for any non-trivial web page. Iterating the DOM through querySelectorAll to replace items at load time? Yikes! So apparently with Sciter you can either have minimal code or acceptable performance. Got it. Would rather have my cake and eat it too.
CSS prototype property is a Sciter specific extension.
When the engine computes styles it does [if needed] this (pseudocode):
Object.setPrototypeOf(element, thatClass);
element.componentDidMount();
on applied elements.There is no "performance sacrifice" in case of handling prototype properties.
Prototypes are switchable if needed:
div.beer { prototype: Beer url(...); }
div.beer:hover { prototype: BeerHovered url(...); }Re: Virtual DOM is pure overhead (2018)
#215Note that a virtual DOM is pure overhead if you already have a real DOM to work with . That's kind of the ignored superpower of a framework like React, which makes the virtual DOM the authority: there might be a DOM, but there also might not be. Whether the virtual DOM reflects to a real DOM, or native UI, or Qt, or an ASCII terminal interface, it doesn't care. This is also the part that most web devs have the hardes…
This is the true power of the VDOM, to abstract the view from platforms.
Why be a web developer when you can be a cross-platform app developer?
That's why I don't use Svelte and other web SPA frameworks...
Re: Virtual DOM is pure overhead (2018)
#216(2018)
Re: Virtual DOM is pure overhead (2018)
#217Software developers: well yes, 99% of the cycles I use are completely needless, but it's still plenty fast enough!
Which we justify with the idea that a framework like React is abstract, hence expressive and productive.
Excuse me? Abstract? React is absurdly low level.
25 years ago I was coding in Borland products. You visually drag you UI together. Link events with a click. Drag data sources and fields into UI to do two-way binding. Tooling chain? What tooling chain. There's a build and a run button. No weird text config files or CLI crap. And every setup is the same.
25 years later we're worrying about painting frames. We're pissing away impressive hardware performance whilst simultaneously not actually achieving abstraction. That's a double fail.
Re: Virtual DOM is pure overhead (2018)
#218I'd argue this is essentially just an optimized (and therefore potentially more buggy) virtual dom. Svelte is being smart and skipping comparisons in the places it knows the result is static. That's nifty. But it also means you have to depend on svelte getting it right every time, in all scenarios. Long term - I think this is probably the right approach, but it feels very similar to the -03 c++ optimization flag: The…
Tell us you've never tried Svelte without actually saying you've never tried Svelte. You would have likely not said this if you had ever looked at Svelte-compiled JS. The amount of mutation is surprisingly small and easy to follow. Especially when coming from a world with JSX.
> "it's building a vdom engine specific to your template"
Because that's... exactly what it's doing. It's doing it at compile time, and so yes - the amount of mutation in the output is small, which is not surprising at all because most templates are fairly static.
We can quibble over exactly what a VDOM is, but I don't really know that tracking only a subset of the DOM the app might change (aka: svelte) vs the entire DOM (aka: react) really matters. In both cases you need to map changes to DOM updates, Svelte is just being smarter about it.
Re: Virtual DOM is pure overhead (2018)
#219Earlier quoted context omitted.
innerHTML doesn't preserve event handlers. So you're either reassigning event handlers over and over or relying on delegate handlers everywhere. And while your statement makes intuitive sense regarding performance, actual measurements show clearly that idiomatic Svelte (and other modern frameworks) routinely beat VDOM-based efforts handily in their idiomatic cases and often even when folks jump through the performanc…
From what I know React does not register event handlers on individual nodes, but rather on root component. Then it uses virtual events from it’s pool in your callbacks.
Re: Virtual DOM is pure overhead (2018)
#220Earlier quoted context omitted.
1. I think you accidentally a tag 2. Your example would have atrocious load time implications for any non-trivial web page. Iterating the DOM through querySelectorAll to replace items at load time? Yikes! So apparently with Sciter you can either have minimal code or acceptable performance. Got it. Would rather have my cake and eat it too.
My sample is correct. CSS prototype property is a Sciter specific extension. When the engine computes styles it does [if needed] this (pseudocode): Object.setPrototypeOf(element, thatClass); element.componentDidMount(); on applied elements. There is no "performance sacrifice" in case of handling prototype properties. Prototypes are switchable if needed: div.beer { prototype: Beer url(...); } div.beer:hover { prototyp…
"Those who do not learn from the past…"