Live data from Hacker News

Virtual DOM is pure overhead (2018)

svelte.dev

21–30 of 293 posts

Re: Virtual DOM is pure overhead (2018)

#21
Compare the design of Featherstitch [1], in contrast to BSD's soft updates.

(I wonder what happened to Featherstitch.)

[1]: https://lwn.net/Articles/354861/

It's a common pattern that you have a list of items of work to be done which in principle you could know ahead of time, but in practice it's better to track at runtime (even though it means the computer ends up repeating the same calculation again and again).

Re: Virtual DOM is pure overhead (2018)

#23
post #12

The most important line: > It's important to understand that virtual DOM isn't a feature. It's a means to an end, the end being declarative, state-driven UI development. Declarative, state-driven UI development is a valuable abstraction. I really hope readers take this to heart, rather than the article title becoming a new meme.

Declarative state-driven UI is great, but personally, I really prefer the way e.g. knockout does it over react. It uses observables and publish/subscribe to issue updates to DOM elements directly where they're needed. You may not like knockout, but it shows how virtual DOM isn't a requirement for declarative state-driven UI.

Re: Virtual DOM is pure overhead (2018)

#24
post #12

The most important line: > It's important to understand that virtual DOM isn't a feature. It's a means to an end, the end being declarative, state-driven UI development. Declarative, state-driven UI development is a valuable abstraction. I really hope readers take this to heart, rather than the article title becoming a new meme.

They note right after that:

> it turns out that we can achieve a similar programming model without using virtual DOM — and that's where Svelte comes in

The abstraction is valuable, but its cost need not be so high. I do wish they'd elaborate on what Svelte does differently though, or link to another post which elaborates.

Re: Virtual DOM is pure overhead (2018)

#25
post #20

While this may have been true previously, React’s new concurrent mode can leverage a Virtual DOM to split actual DOM updates over animation frames, to achieve perceptual improvements over synchronous DOM updates. Svelte’s AOT compilation approach, I believe, is limited in these kinds of time-spanning deferrals, though I’d love to be proven wrong! https://reactjs.org/docs/concurrent-mode-intro.html

Man I've been waiting for this for so long.

Re: Virtual DOM is pure overhead (2018)

#26
post #3

I thought most of the JS world know that virtual DOM is slow and ahead-of-time direct binding is the way forward at this point - why do something expensive inside your users browser when it should be done on the developer's machine? Svelte will either take over, or React will get patched to start doing this in a major new release. It could go either way at this point.

I doubt Svelte will take over. Although I really like Svelte, and worked with it before React, the tooling with React is simply superior. Besides, React already mentioned in one of their introduction tutorials that they are considering taking Svelte's approach at one point. Developers choose the tools that makes them productive and that are enjoyable, not the ones that are most efficient (otherwise we'd all be writing assembly code)

Re: Virtual DOM is pure overhead (2018)

#28

Earlier quoted context omitted.

> This article avoids the fact that declarative programming has proven to be more pleasant for most people. No it doesn't. Second-to-last paragraph: "It's important to understand that virtual DOM isn't a feature. It's a means to an end, the end being declarative, state-driven UI development. Virtual DOM is valuable because it allows you to build apps without thinking about state transitions, with performance that is…

You're right! Seems like I skimmed over that part. My point still stands, though.

Ease of use is definitely important - but 9/10 programmers not familiar with either Svelte or React, learning either for the first time, would prefer Svelte.

There's many good reasons to use React - mainly the React ecosystem - but simplicity is not one of them.

Re: Virtual DOM is pure overhead (2018)

#29

The blog ends with > But it turns out that we can achieve a similar programming model without using virtual DOM — and that's where Svelte comes in. Ok. I’m convinced in principle but is there a follow-on blog that describes specifically what Svelte does differently?

It compiles the code into vanilla JS that directly updates the DOM on state changes.

Re: Virtual DOM is pure overhead (2018)

#30

The blog ends with > But it turns out that we can achieve a similar programming model without using virtual DOM — and that's where Svelte comes in. Ok. I’m convinced in principle but is there a follow-on blog that describes specifically what Svelte does differently?

There's a better explanation of the differences here: https://svelte.dev/blog/svelte-3-rethinking-reactivity

  Svelte is a component framework — like React or Vue — but with an important difference. Traditional frameworks allow you to write declarative state-driven code, but there's a penalty: the browser must do extra work to convert those declarative structures into DOM operations, using techniques like that eat into your frame budget and tax the garbage collector.

  Instead, Svelte runs at build time, converting your components into highly efficient imperative code that surgically updates the DOM. As a result, you're able to write ambitious applications with excellent performance characteristics.
Post reply on HN