Live data from Hacker News

Svelte: $derived can now be overwritten

github.com

31–40 of 55 posts

Re: Svelte: $derived can now be overwritten

#31
post #9

Earlier quoted context omitted.

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 w…

"There's only one component per file" If you don't do this in React, its your own fault.

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 :)

Re: Svelte: $derived can now be overwritten

#32

As someone who has not used Svelte 5: What is the significance of his change?

before this change, derived values were readonly (it makes sense because, if you change the derived value, what's going to happen to the underlying value ?) but now they are writable.

Re: Svelte: $derived can now be overwritten

#33
post #18
post #4

People who have migrated a large enough production codebase to Svelte 5, what's your devex like?

As much as I appreciate Svelte, the React devex is unmatched. I built a client-side app using Wails with Svelte 5 and I found myself wanting React's seamless devex and vast ecosystem. Once I migrated over to React it was like a huge handicap was lifted. Svelte is great. But if you're in a time crunch and you don't have a specific technical requirement that makes React a bad match, I don't think Svelte is worth it. A…

I think i'm about a chapter behind you.

I'll add devex extends to TSX/JSX itself too, the editor support and language server experience is miles ahead. Alternative formatters/linters like Deno, Biome, oxc etc. all have great support out of the box too, not so much for svelte.

For when react is a bad match; I'm investigating solid instead for this reason.

The svelte ecosystem is in a particularly unfortunate spot right now comprising of single/few author projects that were starting to stabilise but now have a svelte 4 -> 5 migration shaking things up.

Re: Svelte: $derived can now be overwritten

#34
post #6

Wow, the optimistic UI example is so simple: https://svelte.dev/docs/svelte/$derived#Overriding-derived-v... I wonder what Ryan Carniato, the author of Solid, thinks of it.

He’s been discussing writable memos for Solid 2.0 off and on for a bit. While the other response is right that you can roll your own, it seems pretty likely this will be a first class thing in Solid too.

Re: Svelte: $derived can now be overwritten

#35
I’m currently building the back-end for my startup in C# using EventStoreDB and CQRS. I have an initial front-end application written in Svelte from two years ago as a PoC. It was a treat writing and designing it and I can’t wait to do a second pass with all these awesome Svelte updates!

Re: Svelte: $derived can now be overwritten

#36

Agh, I understand why runes were implemented, but I still can't get myself to like them. It feels like Runes take away from what made Svelte Svelte (the simple, concise syntax), and changes like this seem like slow concessions back in that direction anyway.

You just have to build a big project with Svelte 5 and you will come to like them. A lot of magic is okay for simple application, but when you want to build anything that scales Svelte before runes was just horrible. With Svelte 5 and Runes you can look at any component and instantly know what it does. You couldn't do that with Svelte 4 unless you wrote the whole code yourself.

I think that's actually the core of the problem. It's the right choice for big projects. But Svelte was an absolute joy to use when brewing up a small or medium size project that you want to just work first time.

Runes are the right choice for the library, but there is still a loss there.

Re: Svelte: $derived can now be overwritten

#37
My experience with using Svelte 5 in production the last few months is that while runes are an upgrade to the magic of previous Svelte versions, it's still too much magic to easily reason about complicated state. This seems like it just adds to the mental overhead. Harris says it's "sacrificing a little bit of purity in service of pragmatic goals" but I don't find it very pragmatic to be debugging glitches, lost reactivity etc which I find myself doing exponentially more as our project grows. The compiler definitely makes simple code snippets look pretty but there was a reason the magic syntax didn't find itself in Vue[1], which in my limited experience has a much more intuitive reactivity model.

1: https://news.ycombinator.com/item?id=37592471

Re: Svelte: $derived can now be overwritten

#39
post #9

Earlier quoted context omitted.

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 w…

"There's only one component per file" If you don't do this in React, its your own fault.

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.
Post reply on HN