7 ms·
People loved React because of VirtualDOM. Now JS libraries advertise themselves based having no VirtualDOM. Can someone explain this to me?
by tarkin2 6y ago
People loved React because of VirtualDOM.
Now JS libraries advertise themselves based having no VirtualDOM.
Can someone explain this to me?
- deleted 6y ago[deleted]
- curist 6y agoVirtualDOM is more of an implementation detail IMO. What I love about React is for its declarative API and we can compose components easily.
- ryansolid 6y agoI agree. I love that about React. I think all UI libraries could learn a ton from React.https://medium.com/@ryansolid/what-every-javascript-framework-could-learn-from-react-1e2bbd9feb09 https://medium.com/@ryansolid/what-every-javascript-framewor... But it isn't something that completely gets abstracted. There is a reason it has been so difficult to make a non-virtual Dom version of React. It isn't impossible, but has yet to fully flesh out despite attempts by a few projects including members of the React team.
- tarkin2 6y agoSo React needs VirtualDOM? Do people want React not to be dependent on VirtualDOM. Is there a reason/benefit?
- dgellow 6y agoYou might get some answers here, from an SO comment written by virtual-dom’s author: https://stackoverflow.com/questions/21109361/why-is-reacts-concept-of-virtual-dom-said-to-be-more-performant-than-dirty-mode#23995928 https://stackoverflow.com/questions/21109361/why-is-reacts-c... The link has been posted in another comment too, here are some chunks that may be relevant to you: > A virtual DOM is nice because it lets us write our code as if we were re-rendering the entire scene. Behind the scenes we want to compute a patch operation that updates the DOM to look how we expect. So while the virtual DOM diff/patch algorithm is probably not the optimal solution, it gives us a very nice way to express our applications. We just declare exactly what we want and React/virtual-dom will work out how to make your scene look like this. We don't have to do manual DOM manipulation or get confused about previous DOM state. We don't have to re-render the entire scene either, which could be much less efficient than patching it.
- cocktailpeanuts 6y agoPeople loved React because it solved a problem. They just happened to solve it using virtual DOM. but theses next generation frameworks are showing that there's a better way to solve the same problem.
- tarkin2 6y agoVirtualDOM allowed you to update the dom with better performance than before. Is there now a better technique? Why is it better than VirtualDOM?
- ryansolid 6y agoSort of. I don't think you can write off the virtual Dom. But this is basically my area of research. I'm saying that a specific approach to reactive programming is more performant. I have an article for that too: https://medium.com/better-programming/the-fastest-way-to-render-the-dom-e3b226b15ca3 https://medium.com/better-programming/the-fastest-way-to-ren...
- tarkin2 6y agoThanks. The whirlwind of changing benefits of various frameworks can be rather confusing. I do wonder how much this matters for most apps and at what cost of complexity it brings. But advancements in the field is a obvious good thing.
- Aeolun 6y agoFrom my perspective, the things are a bit like this: 1. Make all updates manually with jQuery. This is fast, but hard to keep track of. 2. React, create a virtual DOM, then compare the current DOM with the virtual one, and figure out what needs to change. 3. Solid, Svelte, don’t create a virtual DOM, but have the JS compile all the possible changes so you can make them directly in the DOM like with jQuery.
- nsomaru 6y ago
- fabiospampinato 6y agoReact is my UI framework of choice and I don't care one bit about the VirtualDOM or any of its internals for that matter. I would bet a surprising portion of React's userbase wouldn't even know what the virtual DOM is.
- lucideer 6y ago> People loved React because of VirtualDOM. I don't believe this is true. VirtualDOM is a means to an end for React. People love that "end", but they do not love the means by which it is achieved. Maybe one could argue that people love VirtualDOM because it allowed this "end" to be achieved, but I still think every React fan would much prefer it if was doable without VirtualDOM. It is actually "doable" without vDOM but doing so would be much less scalable and require more care from the user of the library.
- chrischen 6y agoI think he may simply be referring to the fact that VirtualDOM/Shadow DOM was one or the “features” React was advertised with initially.
- k__ 6y agoThese compilers work like a library with virtual DOM, but compile it away before deploying. So, in theory, you get VDOM goodness, without the bloat.
- zelphirkalt 6y agoSome people thought they must use VDOM to get things done efficiently, because "All those updates to the DOM will make the browser repaint and everything will be slows! Oh no! We must use VDOM!" This library apparently proves them all wrong, by using the normal DOM in a clever way.