4 ms·
Debugging the svelte compiled code is easy though, it has an order of magnitude less indirection and layers than equivalent React code. Ever got a stack trace i
by PudgePacket 7y ago
Debugging the svelte compiled code is easy though, it has an order of magnitude less indirection and layers than equivalent React code. Ever got a stack trace in a react event handler? 30 stack frames. Svelte handler? 3.
This is one of the reasons Svelte is much faster than React.
- onion2k 7y agoThis is one of the reasons Svelte is much faster than React. Possibly an unpopular opinion here on HN, but if the framework is actually making a difference to the speed of your app then you've probably made some horrible mistakes in your part of the code. React apps aren't slow because of React. Vue apps aren't slow because of Vue. Svelte apps aren't slow because of Svelte. And so on. Framework developers work hard not to get in the way, and they do a damn good job. If your app is slow then it's very likely to be your own fault. There are React apps out there that handle tens of thousands of DOM elements at once at a solid 60fps. React doesn't automatically mean slow at scale. Likewise I could write a Svelte app that's struggles along at 5fps. Svelte doesn't automatically mean fast. There are edge cases where an app is really pushing what the browser can do, and that's where the choice of framework really makes a difference. In those cases which framework is the right choice depends on the app - it's not simply a case that X is always better than Y. If you're updating tons of DOM elements then Svelte is a good choice. If you have lots of DOM elements but you're only updating a few then React (or any virtual DOM based framework) probably works better. But if your app is a glorified To Do list as so many really are, there's no excuse for it to be slow in any framework.
- PudgePacket 7y agoBroadly I agree with you, though my personal opinion is that Svelte is also more pleasant to use, so it really only loses out to React in ecosystem. I've also used React for years and have used it much more than Svelte, so I may be biased from seeing all the warts of React. Being small & fast enables real business use-cases that just weren't possible before, eg https://artemdemo.com/static/2f8acbe19c0ba4ec4d98e06e6b8fd85b/2fc68/svelte-pos-twitter.jpg https://artemdemo.com/static/2f8acbe19c0ba4ec4d98e06e6b8fd85.... Billions of people around the world are coming online in recent years, and they're using budget $100, underpowered android phones. Every little difference in performance is magnified for them.