Why Svelte? (The Short Version)
I’m preparing an introductory talk on Why Svelte for the March Svelte Society NYC meetup so here are my talk notes.
Ryan Atkn wrote a longer version here.
Why is it called Svelte?
Attractively thin, graceful and stylish.
What is Svelte?
Svelte is a compiler, not a library - it takes your Svelte input and turns it into server rendered HTML, static CSS, and clientside JS, and it can build to WebGL, iOS, Android, and Web Components.
In a library, the code that you write is the code that runs. You have to trade off features vs code size.
With a compiler, the code that you write can compile to all sorts of formats, so your solution space gets much larger, while also being able to turn code into efficient low level equivalents. You can include features like styles, transitions, and FLIP animations without adding code size if it isn’t used, or building in compile time accessibility and unused CSS checking.
Svelte in Rich’s words
In 2019 Rich did a series of 3 talks that explored different viewpoints of Svelte:
- Computer, build me an app - Svelte as a compiler that takes your component code and turns it into vanilla JavaScript, that manipulates the DOM directly. This means bundles are smaller, which means for faster download and startup times.
- Rethinking Reactivity - React reruns too much, memoization and amortization APIs are abstraction leaks. Svelte 3 moves reactivity out of the component API (
this.set()
), and into the language (=
and$:
). Spreadsheets and Reactive Programming is approachable to more people, like Svelte is with the HTML approach. - The Return of Write Less, Do More - Svelte lets you write less code with better tooling support because HTML is the language of the web. Writing less lets you do more. Taken to an extreme it may let a lot more people create software and save the planet.
Benchmark Hijacks:
- https://twitter.com/Rich_Harris/status/838115880680710144
- https://twitter.com/Rich_Harris/status/1065992585095929857/photo/1
- https://twitter.com/rich_harris/status/1200805237948325888?lang=en
- https://twitter.com/jpriceio/status/965964676273188869
Basically, Svelte is fast enough. I don’t really care about who is fastest.
Why I enjoy Svelte
This is a rehash of a blogpost I did
- Batteries Included
- The Joy of Mutability
- $ugar $yntax
- Two Way Binding
- Stores
- Good Docs
- Simple Internals
- It is easy to contribute! Here’s how
It is still Early Days
Most of all, it is fun and small. Ever felt like you were too late on a framework or community? Now is your chance, there’s very little baggage and a lot of blank space for you to color in: