by preommr · 5y ago · 0 comments
The jump from "whatever js was in 2014" -> angularjs junk -> react/vue/angular was pretty big.
But now the glamour is gone and we're moving into the phase of actually having to maintain some of the things we built and the wear from bad decisions is starting to show.
-----
Svelte also seems like the cool new kid on the block. Svelte surprises me in how much people fawn over it. I really don't understand the hype since I don't think it's a huge jump forward, and there's also a lot of "misunderstandings" about it in comparison to other frameworks.
Like one thing I've seen a lot is people mention how it requires less code, but it's not that much smaller. It just looks smaller for small test cases where there are like 8 lines of code or because svelte makes stylistic choices that have tradeoffs that aren't immediately obvious. If you take a loot at react/vue, they're not that much bigger for realistic component size.
Anyways, front-end framework discussion is long and muddled and confusing. I wanted to make a point of how svelte people often confuse the engineering/implementation vs the philosophical approach in frameworks. Things like svelte's bundle size being smaller is because other frameworks don't put as much emphasis on it. I was going to say that react is bloated and that preact is much smaller, but looking it up it seems like somehow react is 2.6kb, preact is 4kb, and svelte is 1.5kb. Angular is 62kb. Which proves two points, react/vue can be smaller if it wants, the approach it takes doesn't limit it and that things move so fast that somehow preact makes bigger bundles than react.
React/Vue/Angular you have to learn the build system as well as the ins and outs of the framework, and there are too many opinionated ways of getting started.
```
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js"></scrip...
var app = new Vue({ el: '#app', template: "{{message}}" data: { message: 'Hello Vue!' } })
```
A lot of the build problems with react/vue also exist with svelte. In fact it's even worst with svelte because it's compiled only (which is it's unique selling point) whereas vue can be used in a much more progressive manner. React is a little bit harder because of jsx, but it's still not that much more complicated.
Build-wise, parcel supports jsx/vue files out of the box. Plus React/vue both have cli tools that I don't like and wouldn't recommend, but are super easy to get started with.
And this all comes with the giant caveat that react/vue make progress which can lead to confusing versions. Svelte is a lot younger (kind of, it came out a few years back, so idk) so it hasn't had to cross that bridge yet. And even then, there was the confusion with Sapper. I highly doubt that svelte is going to be immune from the fast-paced nature of these frameworks.
Look at VueJS and React installation pages and it's easy to see the problem with modern frameworks.
https://v3.vuejs.org/guide/installation.html#release-notes https://reactjs.org/docs/add-react-to-a-website.html
So a lot of the abstractions that make life pleasant simply go away.
The in-browser dev tools (svelte tools) lag far behind vue dev tools but it's newer.
react is used with react-dom [1] which is a 121kb minified[2]
[1] https://www.npmjs.com/package/react-dom [2] https://unpkg.com/browse/react-dom@17.0.1/cjs/
I can see how that'll turn around to bite me once the code base gets more complicated though
React can’t get any smaller because of the approach, not because they don’t want to. That’s why it doesn’t include so much out of the box (eg styling, animation, state management).
TLDR:
- it comes with batteries included
- mutable syntax is the simplest possible mental model
- sugar syntax for very common tasks is a norm, including for state management
- docs are fast and good
- internals are simple to understand (i can genuinely fork it if i ever disagree with decisions - good luck doing that for react)
- and other smaller items.