top | item 43477782

(no title)

snide | 11 months ago

I'm almost finished with a large, complex app written with Svelte 5, web sockets and Threlte (Three JS) [0]. Previously, I'd written React for about a decade, mostly on the UI side of things.

I vastly prefer Svelte, because of how clean the code feels. There's only one component per file, and the syntax looks and writes deceptively like vanilla JS and HTML. There's a bit of mind-warp when you realize Svelte doesn't want you passing components with props as props into another component. Svelte gives you "Snippets" instead, which work for some reusability, but are limited. It sort of forces simplicity on you by design, which I like. Most of React's deep nesting and state management doesn't exist in Svelte and is replaced with simple, better primitives.

The bigger gain though for me was Svelte(kit) vs. Next JS. It's very clear what is on the server and what is on the client, and there's none of that "use client" garbage with silly magic exports for Next JS things. The docs are great.

Svelte's biggest disadvantage is that the UI library ecosystem isn't as large. For me that wasn't as big of an issue because it was my expertise, but everyone else looking for a drop in UI library will find the Svelte versions a little worse than their React counterparts.

Because svelte is compiled, it also is by default very snappy. I think choosing Svelte would likely give most devs a speed boost vs. the spinner soup that I've seen most React projects become. A lot of that is going to be in the skill of the programmer, but I love how fast my app is.

[0]: https://bsky.app/profile/davesnider.com/post/3lkvum6xtjs2e

discuss

order

ansc|11 months ago

>It's very clear what is on the server and what is on the client.

Is it though? Your `+page.svelte` is rendered on the server as well. Not only `.server.` is run on the server.

rafram|11 months ago

Yeah, this is SvelteKit's biggest weakness. Easy to write code that seems to work until some unusual confluence of circumstances makes it run on the client when you've always tested it on the server, or vice versa, and it breaks. I still really like it for personal projects, but I think I'd want a clearer client-server separation for anything more complex.

strangescript|11 months ago

"There's only one component per file"

If you don't do this in React, its your own fault.

Toritori12|11 months ago

Maybe things have changed now or I was just a bad react dev but the way hooks works kinda force you to have many child one-off components to not trigger rerenders in the whole component when only a small part was connected to that part of the State being updated. Having all these one-offs components in different files was painful.

vermilingua|11 months ago

Unfortunately some of us work with other people, and refusing to let them merge code we don't personally agree 100% with is a great way to stop working with other people :)

morcus|11 months ago

I also don't really see why this is a positive. If you have too much in a file, then split it off? It doesn't fundamentally add or subtract and complexity either way.

snide|11 months ago

Well. I think that's sort of what I like about Svelte. There's a lot less opportunity to make bad decisions.