Reputation: 2432
Svelte 5 introduce runes, and recommends now to write:
let foo = $state(42);
instead of the elegant
let foo = 42;
I can understand why it makes sense in React… but since svelte is a compiler, why can't it automatically compile let foo = 42;
into its rune equivalent? I guess that because sometimes one might NOT want to assign something via a rune… but it which case would a standard let be better than a "rune let"?
Upvotes: 0
Views: 249
Reputation: 185180
There are multiple reasons:
Proxy
, which can also cause certain issues and will impact performance since every access goes though said proxy.$state
. Svelte 5 moves away from all the "magic".Magical, not magic
There's a subtle line between something feeling magical, and something feeling like magic. We want Svelte to feel magical — we want you to feel like a wizard when you're writing Svelte code. Historically I think Svelte went too far into magic territory, where it's not 100% clear why things work a certain way, and that's something that we're rectifying with Svelte 5.
Upvotes: 1