Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Is Svelte lean and pragmatic or missing something?
15 points by StefanWestfal on Jan 17, 2022 | hide | past | favorite | 8 comments
Context: I am a full stack developer that uses React to build simple UIs for technical simulations.

When working with React I spent a lot of time, also out of curiousity, on different solutions for certain problems (Think of Redux, MobX, and Recoil or React wrappers like React-Konva). With Svelte I don't do that. It seems most basic functionality is included in a thin layer of abstract above HTML, CSS, and JS (ref. The truth about Svelte by Rich Harris) and the Svelte standard library. From state management, reactivity, and with SvelteKit, to SSR and code splitting. For problems not covered is was, until now, always easy to use TS/JS.

Question: is Svelte lean and pragmatic or is it missing something?

Note: I know React, use it, and like it (especially with hooks & Redux-Toolkit). As I am far from senior, maybe there are some complexities I am not seeing yet.




My main concern which made me switch back to NextJS was debugging with useful error messages, given the Svelte system does different things; when I played with it for a graph visualization thing, it hadn’t had all the edge cases found so I felt like getting into bigger project I had trouble finding where my bugs were when I was using Svelte;

that was at least a year ago so if those issues are resolved then it’s a compelling framework to play with for sure, I like how Svelte feels just like HTML/CSS/JS and Svelte performance could be superior to React if certain claims are true about disappearing framework vs virtual dom. Not sure how SSR impacts those performance pros and cons between Next and Svelte so it’d be interesting to find published and updated latency benchmark numbers for both.

React hooks can be different to reason about though because of immutable state patterns vs two-way data binding; I actually really like the hooks and immutability ideas, but two way binding is much more elegant and simple sometimes. Edit: also those don’t have to be exclusive


Good point, maybe this is an issue in bigger projects. I don't have experience here yet.

Regarding debugging and errors, it feels that less code and so much features being already included, and thus out of "one hand", seem to reduce bugs for me.

Having a complier could also open doors to catch bugs at compile time.


Not familiar with Svelte, but definitely see how React ecosystem favored overengineered solitions like redux etc. for a while.

Last versions of react seems to have overcame most of that burden though.


That's why People, Svelte is revolutionary framework. Svelte Stores(state management) is such a joy to use.

It has good developer experience, but not much usage as say React.


I don't think you're missing anything — part of Svelte's value is in the name :)

Some other benefits that I like:

  — Styles are included so you don't need a whole other library for doing styling. Automatic component-scoped CSS is great. You can also include whatever your favorite compile-to-css language is.

  - It's faster than React because there's no virtual dom. I've run into performance issues a lot with React and not much with Svelte.

  - Less boilerplate. According to this talk, React components translated into Svelte components have around 40% fewer characters: https://www.youtube.com/watch?v=BzX4aTRPzno

  - Less JS bloat!* The actual Svelte library gets compiled away so you don't need to include e.g. the entire React runtime. *(There _is_ a crossover point when you have many many Svelte components where the bundle size will be more because each components has self-contained duplicated code, but my understanding is that it's pretty high).

  - Use the HTML/CSS/JS/TS I already know. There's a little "magic" in the compiled reactivity system, but I've found it to be very minimal and easily understandable. I don't have to learn much to be very productive in Svelte.

  - The interactive documentation. It's stellar. I can change all the examples they give and play around with things. The REPL is also super useful when asking questions to other devs about Svelte: https://svelte.dev/repl/

  - Batteries included — Styles, animations, transitions, stores... all of these work really well together and I rarely have to go outside of Svelte itself.
And SvelteKit is taking all this to the next level with making Svelte available throughout the full stack. Heck, I'm making a SaaS boilerplate built on top of SvelteKit because I love it so much: https://sveltesaas.com/

Some drawbacks to Svelte:

  - It's not as popular as React so you're not as well supported when developing.
 
  - The reactivity system can be a little magic (for example you can't do array.push() to trigger a reactive update).

  - You have to learn the templating system instead of just using the JS you already know. A little unfortunate, but I honestly kind of like using templates — I don't enjoy JSX at all.


Please don't format prose as code.


whoops, can't edit it now unfortunately. Didn't know that that's what indenting did


Svelte really is a game changer!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: