Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They really are an improvement. Tracking data flow in a complicated component (bound props going in both directions, derived state, …) was terrible before runes — you just had to rely on compiler magic, which worked until it didn’t. Now it’s more or less obvious.


I wish they had found a way to make the compiler just work. No longer having the ability to update the DOM by updating bound variables eliminates one main reason I wanted to use Svelte in the first place. I still love SFC though.


> No longer having the ability to update the DOM by updating bound variables

What do you mean by that?


In Svelte, traditionally, changing the value of a variable updates DOM elements using that variable.


Right, and what makes you think you can't do that in Svelte 5?


The release announcement? https://svelte.dev/blog/svelte-5-is-alive

   let count = $state(0);
You can't just set a variable anymore, you need to use runes. Which is silly - I shouldn't need to tell Svelte this is reactive, any variable referred to inside the HTML in the component is logically reactive and Svelte should know this. Like it used to. This is why we had a compiler.

I should point out that indeed (as you're correctly pointing out) updating bound variables looks the same, just that declaring them sucks. I don't really trust they won't do similar things to updating bound variables though.


On the one hand, yes, it's annoying to have to explicitly declare state. On the other hand, it's much easier and clearer to declare derived state now. Pre-Svelte 5 code had a lot of this:

    let someState = someOtherState.thing;
    $: someState = someOtherState.thing;
Which was awful.

Svelte 5 does still have a compiler, and there's still a lot of "magic" involved — it just asks you to be more explicit about your intentions in some cases. Of course in an ideal world it could just figure it out, but some distinctions (do I want this variable to always update when its dependencies change? or do I just want to set an initial value based on the dependencies?) need to be specified explicitly, and I prefer clear syntax for that explicit specification over the terrible, verbose hacks that you used to have to use in order to prod the compiler "magic" in the right direction.

I was a runes hater, then I bit the bullet and migrated a big app to Svelte 5. Now I get it. You should give them a chance as well.


> Of course in an ideal world it could just figure it out

Yep. We're agreed there.

> I want this variable to always update when its dependencies change? or do I just want to set an initial value based on the dependencies?

Reasonable to default to first, ask the developer to be explicit about the second if needed.

Honestly I still love SFC and Svelte having opinions about CSS and state storage is great. But it feels like this was the wrong direction. The 'magic' is why we used Svelte.

Edit: I think my tone here is a little off due to illness. Sorry if I sound grumbly. Wasn't my intention.




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

Search: