4 ms·
> If code knows which updates to make, it essentially embeds a particular form of the diff algorithm. Having an alternative means of identifying where to make
by atan 7y ago
> If code knows which updates to make, it essentially embeds a particular form of the diff algorithm.
Having an alternative means of identifying where to make targeted updates on data changes (i.e., via static analysis during a compilation step) is not the same thing as embedding "a particular form of the diff algorithm" (which would be a runtime operation). Svelte does not produce anything comparable to a diff algorithm.
> That inevitably leads to more code to write as besides the initial construction of DOM one has to track changes.
With Svelte, there is actually less code to write, as the compiler handles generation of the change tracking code. And even the generated code is minimal and generally leads to much smaller bundles, as no runtime gets shipped with the code. This leads to faster startup times, which is often the real performance bottleneck for SPAs.
> And such manual tracking is not necessary optimal as the diff algorithm has a global picture and can target the globally optimally set of mutations, while manual in-component tracking optimizes for a particular component.
Can you offer an example where a "globally optimal set of mutations" would be different from the set of mutations Svelte would make on a given change?