Svelte 3: Rethinking Reactivity
svelte.dev
svelte.dev
> Svelte is giving us a warning:
> A11y: <img> element should have an alt attribute
> When building web apps, it's important to make sure that they're accessible to the broadest possible userbase, including people with (for example) impaired vision or motion, or people without powerful hardware or good internet connections. Accessibility (shortened to a11y) isn't always easy to get right, but Svelte will help by warning you if you write inaccessible markup.
Thank you! We accessibility advocates have wanted this kind of checking to be built into mainstream development tools for years. I hope Svelte becomes popular for this reason alone.
Tell me how you intend it to be used and I’ll see if that matches what I think I want (miss-wanting a different topic!).
One small question about some of the pragmatic choices in Svelte 3: What was the decision process behind choosing to smuggle the new reactive features under a "standard" JavaScript skin? ($:, export let, etc.) Is it just to avoid needing to rewrite all existing JS tooling — parsing, syntax highlighting, linting — or is there something deeper going on?
It's exactly that — there's so much tooling in the JS ecosystem that we can lean on, and by inventing new syntax we'd be throwing all that away. It'd be great if we could do `prop answer = 42` and `a <= b`, but it's just not worth it — once you get used to `export let` and `$: a = b` it quickly becomes second nature, we've found.
Hey Rich have you seen Imba?
It's not reactive, but it doesn't need to since everything is memoized. I think it's interesting that they made their own language to solve the front end problem.
They used it to build https://scrimba.com/ which is pretty awesome.
Memoization certainly makes Imba a lot faster than VDOM-based frameworks. Of course, it's only really beneficial when not many things have changed!
Your article says about `count += 1` that "we can do all this without the overhead and complexity of using proxies or accessors. It's just a variable."
But it's not just a variable; it's a magic variable that $$invalidates its contents. I'd be much happier to write `state.count += 1` and allow my debugger to step into the proxy in dev mode, but then have the production compiler convert the proxy into a direct call to $$invalidate to minimize runtime overhead and support legacy non-proxy browsers.
You can easily debug reactive variables, either using the `{@debug ...}` tag in the template (https://svelte.dev/examples#debug) or by using `debugger` in your script tag (https://svelte.dev/repl?version=3.0.0&gist=adc35e969343aad60...).
or "Faster, smaller, web apps?"
They seem to be the main benefits for using Svelte.
(Quick example: the countless hello world projects that result in >100KB bundles)
https://www.nytimes.com/interactive/2018/01/27/technology/so...
Ouroboros: the tail recursive self devouring snake!
I didn't even think it was an English word before I watched Rich's (great) talk.
It gives an inkling of the functionality and most importantly avoids “cybernetically” which makes the framework sound kooky.
I'm not sure I like this single components approach and embedding JS in HTML.
The problem with this is that it's too frameworkish.
The big benefit of JSX/React rendering is that it's composable and declarative (as it's just functions), but it's also simple to get - render just returns wanted structure, given the state and you can use simple assert to verify that.
Solutions like angular/vue/svelte rely on custom template parsing which IMO sucks, because it's hard to extend/test without specific template compilers. JSX in contrast is embracing language.
I think that render functions written like in react and data reactivity is the simplest approach to describe application. Seems like VueJS with JSX is closest to this right now.
It would be cool to keep similar API but maybe use compiling to have smaller bundle/older browsers support/different platform support etc.
To be clear by similar API I mean just pure JSX components, where you plugin reactive data, that could be tested without any frameworks and without rendering. This is the simplest way, yet nobody build it yet - MobX + pure React components is close to this (problem is that still rendering is done by React, so rendering isn't most performant - depends on components hierarchy) - with compilation/integration you could make it more performant, but I would keep declararive nature and simplicity of JSX.
This is actually a feature, considering what Svelte does. I know of more than a few efforts to implement similar compile-time production of low level procedural code from React components, but so far nobody's been quite able to do it. And this is despite these efforts coming from some very smart people. The reason this is so hard to do for React is precisely because Javascript is a huge target with a ton of bizarre quirks and edge cases.
> To be clear by similar API I mean just pure JSX components, where you plugin reactive data,
I think Solid.js is the closest thing to this atm. Not React-based though.
Svelte seems to show a lot of promise, but I have a few things that I'm not 100% on.
1. How are the higher level abstractions for Svelte? Any framework can be easy for simple applications, but how easy will this be to reason about as we get to larger applications? React deals with this through a semi-functional mindset. What does Svelte offer?
2. Is there any plans for facilitating incremental rollouts? Changing your application to an entire new framework is not always worth it, and is greatly difficult. I could imagine Svelte being incredibly useful for large-scale, performant applications. However, unless it can be incrementally rolled out, then I can't see how the biggest players will be able to utilise the power of Svelte.
I'd love to see the game changed in web frameworks, and I love the idea of using compilers where possible. If anyone could answer these queries, I'd be very much grateful.
What's the underlying reason for the slowness?
React applications can definitely be written to be performant without resorting to "hacks", typically using immutable data structures (that support reference equality checking) in combination with judicious use of PureComponent/shouldComponentUpdate/React.memo. Also using something like react-virtualized/react-window for large lists/grids.
Is React more difficult to keep responsive as an app grows? What sort of UI paradigms lead to poor performance? Just the phrase "using immutable data structures (that support reference equality checking) in combination with judicious use of PureComponent/shouldComponentUpdate/React.memo" makes it seem like you need lots of in-depth React knowledge and additional packages to write a performance React app.
In many cases, these re-renders return the same render output as the previous render, which means that no changes need to be made to the DOM. These renders are referred to as "wasted", because React went through the work to ask your component "what do you want the UI to look like?" and diffing the output, when nothing actually was going to change.
The two key aspects of optimizing performance in a React app are:
- Decide if the props and state for this component have meaningfully changed
- Tell React to skip the rest of the rendering process for this component (and therefore skip the rest of this subtree as well)
The standard approach for checking for changes is simple reference checks: `prevProps.a === props.a`. For larger amounts of data, this assumes you've updated that data "immutably", by making copies and modifying the copies instead of the originals. This can be done with plain JS objects and arrays, it just can take a bit more diligence. (Libraries like Immer [0] can help with applying those updates immutably.)
For the "skip rendering" part, React has offered several APIs over time, but they all basically boil down to "do shallow comparisons of data, and bail out if they're the same":
- The old / deprecated `createClass()` API allowed use of a `PureRenderMixin`
- Classes have a `shouldComponentUpdate()` lifecycle method where you can implement whatever custom comparison logic you want, and return `false` if the render should be skipped
- Since the typical comparison in `shouldComponentUpdate` is a shallow equality check of both props and state, the `PureComponent` base class was added that does that by default
- More recently, the `React.memo(MyComponent)` API was added to allow wrapping any component (class or function) with that same bailout behavior.
All of those are actual React APIs, not separate packages.
All that said, the React team advises that you should just write the app first, _then_ profile it later (in a production build!) to see where the key bottlenecks are and just optimize those. In most cases, you probably don't even have to do anything - performance will often be sufficient as-is.
React's DevTools have a performance profiling tab [1] [2] that helps show which components rendered for a given update, which makes it a lot easier to track down unnecessary renders. The community has also created various "why did you update?" libs that log unnecessary renders.
[0] https://github.com/mweststrate/immer
[1] https://reactjs.org/blog/2018/09/10/introducing-the-react-pr...
[2] https://www.netlify.com/blog/2018/08/29/using-the-react-devt...
Svelte is pretty well suited to incremental rollouts, because it doesn't have a chunky runtime foundation — it's not as though you have to ship two full frameworks simultaneously. There are some community-maintained adaptors for using Svelte components inside apps for other frameworks, I believe. You basically have to start at the leaf components and work your way in. An alternative approach would be to compile Svelte components to custom elements instead, since they can (in theory!) be used anywhere.
<Box flex flexAlignItems="center" marginTop={5}>
<Heading level={2} caret="down">
Profile info
</Heading>
<Media>
<Avatar id={avatarId} size="small" lazy />
<Media.Block marginLeft={2}>
{displayName}
</Media.Block>
</Media>
</Box>
would be compiled into their simplest forms: <div className="flex flex-align-items-center margin-top-5">
<h2>
Profile info <span className="caret-down" />
</h2>
<div className="media">
<img src="https://www.cdn.com/avatar/{avatarId}" className="avatar-small" lazyload="on" />
<div className="media-block margin-left-2">
{displayName}
</div>
</div>
</div>
I believe the technique is called "component folding". I tried to do it with Babel but it's a real pain.Thanks for putting so much work into exploring alternative ways of making the web faster, because, at the moment, it still requires an immense effort.
I chose vue over react for simplicity and I'll be damned if I don't choose svelte over vue for the same reason and more after this talk.
The gist of Immer is that your framework needs immutable structures, but you want to interact with them imperatively.
It's very interesting, and a reversal of the traditional "functional core, imperative shell" architecture.
Will these always be separate libraries? Is Sapper basically the create-svelte-app for your framework? What's the roadmap for Sapper and integrating Svelte v3 changes?
We've also mulled creating a React Router equivalent, for people who prefer components-as-routes to files-as-routes.
Thank you for pointing this out. To me hooks were always a way to solve problems in React that wouldn't be there if it weren't for React. They help, but come at a cost which barely anybody seems to talk about.
We really want to add first-class TypeScript support.
Yes, please!
Reasoning about hooks is hard.
Basically, I separate out the <script> & <html> section into two files. The <script> part is generated from typescript and combined later before sending it into the svelte compiler.
I am currently working on a gulp build file to streamline the process.
Let me know what you think.
“Write less code”
Svelte has a ways to go to catch up with the leaders on popularity and future breadth, but it is focused on the right problem: reducing the cost/size/effort of making things.
Edit: Some more clarification about why the arguments don't hold for me.
- More code = more bugs
I think code that is harder to understand leads to more bugs, but more characters typed does not necessarily directly result in more bugs, as far as I know.
- Writing code takes more time
Again, it's not the typing that takes time, but thinking of which code to write. If I have to type more, but there's less for me to keep in mind while typing (i.e. lower cognitive load), I'll be faster at that.
As said: yes, readability is important, but that's a different value than "write less code".
I'm trying not to make a judgment about Svelte here specifically since I haven't worked with it yet, and the general concept (of being a compiler rather than working during run-time) appeals to me. That said, concepts like bindings do scare me - with e.g. `useState` I know that the only places that can change `a` are those that call `setA`, whereas it appears that with Svelte, it can also change e.g. in response to `bind:value` attributes? I'm (perhaps misguidedly) afraid that that's saving a few characters at the cost of readability.
Most of the discussions I could find on the topic before writing that post suggested that the error rate per thousand lines of code is surprisingly constant across languages, which suggests that more characters typed does result in more bugs. I learned that from the internet though, so take it with a grain of salt!
It's true that `bind:value={foo}` offers another way to change the value of `foo` besides `foo += 1`, since at that point you're explicitly opting in to two-way binding. If you prefer, you certainly can do the `on:change={handler}` thing instead, but as I argue in the post I think that's less effective at capturing the intent of your code (and gives bugs more places to hide). This is definitely a subjective area though.
It's an interesting subject, but I'd like a causal explanation rather than just the correlation. For example, this would imply that TypeScript code would be more buggy than its Javascript equivalent, since it's the same code I'd write otherwise, with additional annotations. (Then again, there is some code, like null checks, that I don't have to write with TypeScript, so perhaps that evens out.)
> I think that's less effective at capturing the intent of your code
It's been a while since I've worked with Angular.js, the last framework I used with two-way databinding, but now having this conversation I think I recall the main reason it was confusing. A pattern that would sometimes arise is e.g. for a component to receive data through a two-way databinding from its parent, and then likewise passing that on to a child. That could make it very hard to trace where a change was coming from.
It might well be the case that it is far less problematic when e.g. only used to bind form values. Again, I'd have to try it to get a proper feel for it, so I'm looking forward to doing that.
A large benefit with less code is about the signal/noise ratio. If you need plenty of boiler plate logic, you will have less signal that you can physically read & mentally process at a given time. We naturally ignore the noise, but the noise takes screen space & miscategorizing noise leads to bugs.
Less code leads to less bugs, especially high-level bugs, because the programmer can see more signal at a given time, thus being exposed to a larger system.
The study that Rich mentioned could be interpreted as relating to the comprehension of the code, where more code inherently means the system has more information & is more difficult to comprehend.
Re: two-way binding, the data flow is inherently confusing whether you use imperative or declarative logic. Do you want a clear concise representation or do you want to spread out the implementation over more code/files?
So in the case of two-way data binding, if I'm trying to trace how a certain value was be modified, data flow in the opposite direction might count as "noise", in terms of extra cognitive load.
Again, this might not be something that is the case for Svelte, but it's what I observed in Angular.js.
I think my problem with two-way data binding is not so much that it's an additional way to update a value, but that it doubles up as reading and writing a value, and with that makes code somewhat harder to read. However, as I noted in response to Rich, that might not be a problem if that is only limited to variables bound to forms, but I'd have to try it to get a better feeling for that.
But I'm getting off-topic, so the answer is: I don't really have an opinion about Go, but the general principle you describe is not one that attracts me.
I know it's a solved/solvable problem but it feels like better docs and samples in quick start guides would help.
The author is a brilliant developer, but he should narrow his focus on Sapper/Svelte now, beside which he has many other projects (rollup, etc...)
To be clear though, Ractive is still under development by other maintainers: https://github.com/RactiveJS/Ractive.
> he should narrow his focus
Not to speak for him, but I think Rich is an "idea guy" and we'd all miss out if he were throttled to just one thing :-)
> Cybernetically enhanced web apps
That is pretty terrible! It seems to me that the main think that distinguishes Svelt is that more work is done at compile-time? Why not a slogan that says just that?
"Compile-time optimised reactivity." or "Low overhead reactive web apps" or something like that. Cybernetics is nonsense waffle.
Anyway good luck! Seems like a better approach than shadow DOM etc.
Is not AOT compilation is a more traditional name for such stuff?
Dymaxion: dynamic, maximum, and tension -- maximum gain of advantage from minimal energy input.
https://en.wikipedia.org/wiki/Dymaxion
Simply zip all your content into a sleek .ddu file and upload it to the server:
An example use case where this would be valuable: a user hightlights text, bolds it, then highlights it again plus some more text, and bolds it. A naive approach would have: <b><b>This text is bolded</b> plus I bolded this</b> when what you want would simply be: <b>This text is bolded plus I bolded this</b>
Libraries like DraftJS and SlateJS use immutable data structures to parse the input/formatting in the VDOM and reconcile them into "blocks" (basically javascript objects containing the formatting) that deduplicate formatting.
The talk below on DraftJS is pretty good.
https://www.youtube.com/watch?v=feUYwoLhE_4
What's the recommended way to handle a rich text application in Svelte? Is there anything like the above for Svelte?
A good editor would be standalone, with wrappers to make it callable from a framework of your choosing.
Most good rich editors implement their own internal Dom to achieve uniformity across browsers. DraftJs, Quill, Trix... use this strategy. There's nothing unique to react-Dom that benefits rich text editing
I love it. I cannot believe how fast the app load on both first and second time visits. 100% in lighthouse.
I think Svelte is the way to go! I hope the community will accelerate and eventually catch up with React and Vue!
Multiple frameworks have done this for many years, but nobody will listen as everyone is interested in the next new, shiny thing.
I do like Svelte in its latest incarnation though, especially when it integrates with Sapper.
```
function create_fragment(ctx) { var h1, t0, t1, t2;
return { c() { h1 = element("h1"); t0 = text("Hello "); t1 = text(name); t2 = text("!"); },
m(target, anchor) {
insert(target, h1, anchor);
append(h1, t0);
append(h1, t1);
append(h1, t2);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) {
detach(h1);
}
}
};
}```
The framework that has blown me away with it’s simplicity and elegance but power is snabbdom.
It’s small, it’s fast, it’s modular. You can use it with jsx, you can use it with webcomponents if you want. You can type it with typescript. Animations check, custom module extensions, check.
As the recent experiments in wasm has shown, you can make extremely fast vdom diffing that is memory allocator friendly.
So my bet in the future is this. Vdom will be here for a while. It’s simple, elegant and we’ll figure out how to make it faster with newer tricks.
More non web UI frameworks will use similar approaches. React Native is paving wave here but I can see desktop apps and terminal apps embrace the same concepts too.
View as function of state is a very powerful paradigm. State being a simple dumb old nested object. No magic tricks.
Svelte feels too magical. Vue has same issues. It’s hard to reason with magic when you hit edge cases.
You ideally want a simple model in your head so you can build really complex apps by connecting simple axioms of logic.
https://svelte.dev/examples#dom-events Look at the compiled output (the "JS output" tab), it's so readable and stepping through it with a debugger is actually possible for mortals unlike trying to step through code using react (I know, I've had to do it..).
A frequent argument for the use of vdom has been that it reduces Dom trashing. I am willing to bet that if a vdom library has figured out what elements don't need updating, the browser's Dom implementation tuned over decades has that logic built-in. So go ahead and trash the Dom, but batch your updates and the browser's logic will likely not trash more than necessary. And since that logic is implemented in an AOT compiled language, it probably is much faster than a js v-dom
React made writing frontends generally better, but often slower and as rich_harris points out that it entails a lot of developer work to build and use optimizations to speed it up.
Svelte is intended to be exactly that!
Whether performance is an issue depends partly on the kind of app you're building. In my line of work (producing interactive data visualisations etc) it absolutely is. As I talk about here, it's going to become even more important as the 'embedded web' becomes a thing: https://youtu.be/AdNJ3fydeao?t=1498
Bonus thoughts on virtual DOM: https://svelte.dev/blog/virtual-dom-is-pure-overhead
I don't think my post was very clear. I agree that the run-time complexity of svelte is much better than a vdom framework, but it seems like you're just trading that for build-time complexity. Maybe that's the only way to achieve what I'm talking about though. At some point you have to translate from immediate mode to retained mode if you're rendering to the dom.
I also work in interactive visualizations. I think this is one of the areas (in addition to games especially) where vdoms quickly fall short. Once you start animating a lot of SVG elements, it doesn't matter much what framework is under the hood; it's going to crawl. Canvas/WebGL is the only real solution I'm aware of. Does svelte somehow provide a significant speedup in these situations? I obviously need to read up more on what your compiler is actually doing.
Svelte's claim is that converting it into build time complexity is in fact the only sensible thing to do. It doesn't really matter how much complexity is involved in `npm run build` if it means that DX and UX are no longer in tension.
But to answer your point about SVG, Svelte has to obey the same fundamental constraints as any other code, so you will eventually hit performance issues (though you may enjoy this demo https://youtu.be/AdNJ3fydeao?t=1138). One avenue I'm currently exploring is whether the same declarative/compiled model can be used as a wrapper around WebGL APIs, though it's very early days.
I like that. I'm definitely going to have to think on it some more.
> It doesn't really matter how much complexity is involved in `npm run build` if it means that DX and UX are no longer in tension.
As long is it doesn't break. I think Vue has a fantastic developer experience. As long as everything works you have incredible leverage as a developer. But the first time I tried to pass it a large nested object I lost many hours figuring out that I needed to call Object.freeze to prevent it from setting up reactive hooks on the whole thing (once set the data was static).
> One avenue I'm currently exploring is whether the same declarative/compiled model can be used as a wrapper around WebGL APIs, though it's very early days.
Keep us posted. I've done some experimenting on this myself. I built this[0] using a lisp-ish markup language I threw together. Think SVG with built-in support for defining and composing sub-components. The language compiles down to canvas calls at runtime. That version renders to 2d canvas, but I started a WebGL implementation that I haven't finished yet.
It's very much on the radar (I'm a TS convert, personally — Svelte itself is written in TypeScript), we just need to get round to it. The version 3 rewrite was largely about laying the foundations for TS support.
It's an amazing reflection on the velocity of the web & JS ecosystem that React APIs prior to hooks, which were shipped all of 3 months ago, can be sincerely referred to now as 'classical' :-)
Does anyone here have a major, non trivial app in production that's built on Svelte?
- Does it work with TypeScript?
- How does it relate to other reactive frameworks, such as RXJS? Does it make sense to use them together or does the Svelte compiler invalidate the benefits of them?
- Does it work with any existing components?
- There is a lot of static code analyzing tools, like linters, that work with separate JS/CSS/HTML files. Does Svelte have to adapt all those tools in order to make them properly work with a single file component (.svelte file)?
- I believe enabling first-class TypeScipt support would bring more sanity to Svelte-based development.
This is actually quite similar to what PostSharp did with WPF where it injected INotifyPropertyChanged and WPF compiling its getters and setters.
Then it's also similar to KnockoutJS (inspired by WPF), MobX (inspired by Knockout) and Vue (also inspired by Knockout)
You could possibly predict the future of Angular and Svelte by comparing them and looking for ways to cross-pollinate.
One question about version 3. I was wondering if they addressed the issue of how a Svelte code base can grow in size larger[1] than a Preact based codebase the bigger it gets.
[1] https://medium.com/@chrisdaviesgeek/tiny-js-frameworks-preac...
It's true that the incremental cost per-component is higher than with some frameworks. In theory, you hit an inflection point. In practice though this doesn't really happen, because by the time you get there, you should be code-splitting anyway — and each of your code-split chunks have a hard minimum size which is the size of the framework.
This article reinforces that finding by testing the 'RealWorld' project: https://medium.freecodecamp.org/a-realworld-comparison-of-fr.... It's based on an outdated version of Svelte but the broad strokes will be unchanged.
Of course, Svelte is about far more than just bundle size!
Keep up the good work! I think Svelte is really cool. Like I said before, I like the idea of it. I am going to promote it to the rest of my team and hopefully we can give it shot on one of our next projects.
Are web component going to happen with v3? I am trying to combine Python server app with Svelte enhanced HTML and got good results on v2. I noticed they are marked as todo: https://svelte.dev/docs#Custom_element_API
TODO: make shadow DOM optional, and only auto-register if a tag is provided (currently it's required)
Or is it possible already somehow? I tried to use
<svelte:component this={“h1”} ...
but it doesn’t appear to support strings, just Svelte components?Minor suggestion: it should be easier to find how to get started (read install) for people trying to give Svelte a try. I had already played a bit with Svelte before but wanted to try v3 and the only thing I could find about how to install it was in https://svelte.dev/blog/the-easiest-way-to-get-started.
I think Svelte is doing a lot of things right (simple code, computing CSS animations, accessibility built in, focusing on a compiler versus a full on framework) and I can't wait until Sapper is updated to dig in.
I think the VDOM seemed to offer a maxima and people thought it might be a global one (even though in hindsight it seems like a silly proposition). Angular certainly hasn't exactly delivered on performance in any meaningful way that I know of, at least, so maybe the VDOM, even if it was a local maxima, was still the better of the two?
As a basis for a durable design and a way to move forward, clearly we have a better way, though, but that can only be illustrated by a project actually doing well at it.
I think the issue became that the VDOM creates some overhead that making very simple DOM changes can avoid altogether. From what I understand, Svelte sidesteps the VDOM and outputs the smallest amount of code to achieve the desired level of reactivity which might be the better abstraction.
Angular goes a similar way, just look up Ivy renderer on the internet.
Edit: It looks like the goals are a bit different with Angular's focus on Typescript (Svelte let's you do this but is not entirely focused on Typescript). Also not sure if Angular's compiler supports CSS compilation.
But the idea of replacing a framework with a compiler blew my mind, so thank you.
And subverting the labeled statement is a wonderful hack. The kind that sticks.
I’m very impressed overall even if a bit scared from the “bad kind of magic” cited.
The best and self-defining para from article
(Longer answer: what sort of bugs? Was there an issue on GitHub?)
Elm is a compile to JS language with a small footprint (it does still use a virtual-dom though). It would be nice to see a size comparison of the two. https://elm-lang.org/blog/small-assets-without-the-headache
Thank you, contributors!
It's a Sublime Text-inspired navigation tool for Firefox. I use it to jump around between tabs on different workspaces or different monitors. (Yes, I know the default keybinding is bad. I'm going to change that in the post-refactor version.)
My plans are to refactor it for the new Svelte, then improve the fuzzy search, and possibly go cross-browser.
That's not a bad thing - that's the "good" kind of Reactivity and how most UI should be written IMO - it involves significantly less boilerplate.
It's also worth noting that this approach means there's none of the overhead involved in creating proxies.
We're working on a project with MobX 5 and mid project we realized some of our users on iOS 9 or KitKat do not have Proxy.
I think you might want to check out WPF + PostSharp for something very similar to this approach in C# land. I definitely think it's the right approach for reactivity.
The main blocker for me adopting Svetle (and opting for Vue and React) is tooling to be honest. I want code that has a lot of visibility, meaningful stack traces and the debugger stopping in relevant places. If Svetle 3 does everything synchronously (like MobX) I'd love to check it out!
Instead, please put some real async stuffs, how to manage state, how to put state into many small components.
Examples, not just documentation matters.
So, Svelte is compiled into web assembly? If not, given the emitted imperative code is less efficient than emitted web assembly and the emitted imperative code is less concise than the original declarative code, then what would be the advantage of an imperative translation of the declarative Javascript code compared to emitted web assembly or the original?
The code you write in Svelte is reactive/declarative, emitted code is regular imperative JS.