Comment by hsn915
21 hours ago
What we need is not templating. What we need is a native implementation of a virtual dom.
More specifically, a native implementation of the "patch" function:
patch(target_dom_node, virtual_dom)
Where `virtual_dom` is just a plain-data description of the DOM.
Most of the "slowness" of the DOM come from its requirement to be a 90's era Java style object hierarchy.
Don't call it "templating". Just call it "virtual dom". Everyone knows what that means.
A native virtual DOM implementation would also drastically reduce memory overhead since browser engines could optimize diffing algorithms at the C++ level instead of requiring megabytes of JavaScript framework code to be downloaded, parsed and executed on every page load.
Virtual DOM is a useless abstraction, there are numerous libs that perform fine without it.
It's a useful abstraction: you just build the full DOM with every change, a bit like a game engine. It makes so many things simpler.
It's not a free abstraction though.
Other than quibbling over the word "template", how does that differ from what TFA is describing?
The linked proposal has many "features" that would be "needed" if you frame the problem in terms of a "template api", centered around "binding" variables, and what not.
https://github.com/WICG/webcomponents/issues/1069
My proposal only adds one native function with nothing else: no new data types, no new apis.
Doesn't your proposal implicitly introduce the concept of a virtual DOM, which the browser does not have?
You'd need to spec out what that looks like. It adds one new API from the users perspective but much more from the browsers perspective.
Additionally the next generation of Frameworks do not use virtual DOM. Solid and svelte do not. Vue is moving away from it. Signals are directionally where they're all heading.