| > then diffed with the real DOM Diffing with real DOM is slow, majority of vdom libraries aren't diffing with real DOM. As an author of a "vdom" library, I don't like to think about "reconciler" as a diffing algorithm because it is a useless constraint, I like to think about it as a some kind of a VM that uses different heuristics to map state to different operations represented as a tree data structure. > What I wonder is whether the reason for virtual DOM is really just historic, is there anything else that has caused its persistence other than inertia? As a thought experiment try to imagine how would you implement such features: - Declarative and simple API - Stateful components with basic lifecycle like `onDispose()` - Context API - Components that can render multiple root DOM nodes or DOMless
components - Inside out rendering or at least inside out DOM mounting - Conditional rendering/dynamic lists/fragments without marker DOM nodes Here are just some basics that you will need to consider when building a full-featured and performant web UI library. I think that you are gonna be surprised by how many libraries that make a lot of claims about their performance or that "vdom is a pure overhead" are actually really bad when it comes to dealing with complex use cases. I am not saying that "vdom" approach is the only efficient way to solve all this problems, or every "vdom" library is performant(majority of vdom libraries are also really bad with complex use cases), but it is not as simple as it looks :) |
So thanks for listing out some concrete things that may be easier to implement with a virtual DOM. And if there are any other good resources out there, then do share! :)