r/javascript • • Jan 15 '21

Svelte beats react for developer satisfaction in 2020

https://2020.stateofjs.com/en-US/technologies/front-end-frameworks/
346 Upvotes

231 comments sorted by

View all comments

Show parent comments

12

u/csorfab Jan 16 '21

it doubles the work

no it doesn't. operations on a VDOM are much much faster than operations on the actual DOM. Also, it's not "re-applying the same changes again", the VDOM is used exactly for diffing the rendered subtree to the current state so that the number of actual, costly DOM update operations can be minimized. VDOM operations are as cheap as they get.

Svelte is nice, sure, but for most real world use-cases, it's not really that much faster than React.

7

u/dzkn Jan 16 '21

Exactly. 99% of the time you run into performance issues with vue or react, you made a mistake. You would have make many thousands changes every second to hit the limits of the vdom approach.

0

u/[deleted] Jan 16 '21

[deleted]

3

u/SomeRustJunkie Jan 16 '21

This has been debunked

-1

u/Auxx Jan 16 '21

DOM is only slow if you do updates across multiple ticks instead of pre-compiling and batching everything together. React fixes problems for bad developers who don't understand browser's inner workings and write crappy code.

1

u/dzkn Jan 17 '21

Can you elaborate? How would you have done it?

1

u/Auxx Jan 17 '21

Angular is doing it with zones and template compilation. Svelte is using pre-compiled templates as well.

The problem is not that DOM is slow, but how you interact with it. You still have to alter it when using React, there's no way around it, so saying that virtual DOM is fast is completely irrelevant.

What React is doing is that it applies your changes to virtual DOM and at the end of a cycle diffs it to the real deal and then only touches parts which should be changed.

On the other hand Angular compiles special code which tracks data changes bound to each template and updates DOM directly. This approach also changes only those parts of DOM which need to be changed. And zones help to track when these data updates happen. Then at the end of a tick, compiled templates do their job and everyone's happy.

The difference here is that everything in Angular is static and pre-compiled and everything is data driven. React creates a new dynamic structure instead and that always has performance penalty. But static nature has its own issues of course, for example, you can't create new components in run time - they all must be compiled offline and served as part of application.

1

u/dzkn Jan 17 '21

I agree with all this, but not that there aren't valid reasons for good developers to prefer react over angular.