Svelte 5: Runes
I’m not particularly comfortable with some of the nature of the change. Runes are magic compiler symbols, but they look <i>even more</i> like just normal code than was the case before. Previously, Svelte’s reactivity model was very easy to understand, including its limitations, because it was the result of very simple analysis—you can cover the rules in a few minutes without difficulty. It included some things that were <i>obviously</i> magic: $: reactive blocks and $ prefixes on stores.<p>When you had this:<p><pre><code>  let count = 0;
  count += 1;
</code></pre>
… it made reasonable sense, because that’s just normal JavaScript; the fact that `count` was made reactive was basically incidental.<p>But once it’s this:<p><pre><code>  let count = $state(0);
  count += 1;
</code></pre>
This looks like you’ve called a function named $state, and given that you’re talking about migrating from compile-time to runtime reactivity, you might (I think reasonably) expect `count` then to be some <i>object</i>, not just an integer, and so `+= 1` would be the wrong (since JavaScript doesn’t let you overload those operators). But no, it’s instead some kind of decorator&#x2F;annotation.<p>Yes, stores are unwieldy as you scale them up, and definitely have some practical problems, but that createCounter stuff <i>looks</i> fragile. I’m curious how it all works, because it <i>looks</i> like it’d be needing to do quite a lot of control flow analysis, but not curious enough to investigate at this time. But my intuitions suggest it’s probably markedly more complex and difficult to explain, though perhaps and hopefully more consistent.