DEV Community

Discussion on: Why Virtual DOM?

Collapse
 
lexlohr profile image
Alex Lohr

…that's not really how we do web development today in real production use cases.

If performance is your highest priority and the page is rather simple, it is still a sensible choice to develop exactly like this – and I actually did that ~ 3 years ago. Unfortunately, we had a priority shift in the meantime, so I cannot show you the result anymore, but it easily outperformed anything we could have done with react.

However, I partially disagree with your generalization that Svelte and SolidJS is better for development experience…

I would partially disagree, too, because I made no such statement. I merely remarked that they save you the hassle of hand-optimizing DOM manipulations while allowing for similar performance.

React is a compromise – and as I already said, that can be a good thing, too, depending on what you intend to do.

Thread Thread
 
aidenybai profile image
Aiden Bai

I see, personally I would prefer the best performance, but to each their own. I'd like to see the example if you ever get to find it!

I think I misinterpreted your statement there, I thought you were talking about React when you remarked about the "hassle" part.

It can also be noted that using any technology is a comprimise - for example, using DOM nodes generally constrains you to imperative programming, and Svelte constrains you to it's own syntax, while providing extreme performance. I think a better phrasing could be "a means to an end" to provide declarative programming.

Thread Thread
 
lexlohr profile image
Alex Lohr

You're right.

Every library and even using no library is a compromise between time, performance and features (maintenance costs time, so a library that makes it easier will save time).

I'm currently using react at work and it's a rather good compromise, because we work with 4 teams of varying experience on a very complex application.

But back to the original point: a virtual DOM is not a necessity, but merely one way to solve a certain set of problems – and in some (but not all) cases, other solutions might be a better fit.

Thread Thread
 
aidenybai profile image
Aiden Bai

That's a good way to put it, I just rephrased the title of the article so it's a bit more vague, but no longer claims that it's a necessity. Thank you!