Introducing Svelte, and Comparing Svelte with React and Vue (2021)
joshcollinsworth.com
joshcollinsworth.com
But I'm a "hacker type" and don't work in a large tech company. I haven't seen Svelte in any sort of "real tech companies", haven't seen it on job boards, and it doesn't seem a very desirable skill.
Does this mean that Svelte "doesn't work" for large teams, because it lacks the boilerplate of React?
I've been working exclusively with Vue for the last... 6 years. Since the launch of v2. So my mind is already conditioned ;-)
edit: oh nvm, we haven't upgraded our codebase to Vue 3 yet, there are a lot more ".value"'s if you click through to the Vue 3 examples in the original post.
Since vue does not hide the fact that something is a ref, you need to call `myRef.value` to get to the underlying value of `const myRef = ref(10)`.
In a new and currently experimental syntax, you can use `const myRef = $ref(10)`, at which point you can just use `myRef` directly. This will then be converted by the Vue SFC compiler.
Another option is to use a reactive object as the state: `const state = reactive({ myVal: 10 })`, at which point you can just use `state.myVal`.
Oh sweet didn't know that. I keep forgetting to type `.value` and debugging it wastes a couple of seconds here and there.
https://vuejs.org/guide/extras/reactivity-transform.html#ref...
You use the object the same way you use a js variable.
let st = $ref(10)
st = st + 1 // update it and use it like if it was just "10"
But now, st is reactive.
In svelte, top level variables are automatically reactive.
I also like Svelte's "writable store" model rather than React's Redux which forces data to flow a certain way, through the dispatcher.
Svelte Stores make it a little too easy to "shoot yourself in the foot" if you're not too careful though, as you can make data bi-directional, and you can make children set parent data. This makes prototyping super easy and fast, but probably creates massive code readability problems down the line, especially for larger teams.
But just like you said, it can be a footgun if you're not careful.
Context is a Dependency Injection tool for a single value, used to avoid prop drilling.
Redux is a tool for predictable global state management, with the state stored outside React.
Note that Context itself isn't the "store", or "managing" anything - it's just a conduit for whatever state _you_ are managing, or whatever other value you're passing through it (event emitter, etc).
I wrote an extensive article specifically to answer this frequently asked question, including details about what the differences are between Context and Redux, and when to consider using either of them - I'd recommend reading through this:
- https://blog.isquaredsoftware.com/2021/01/context-redux-diff...
But IMHO a lot of that is overkill when your only goal is global state. Context solves that problem very nicely (in conjunction with state and reducer, yes, but context is the big piece there). Prop drilling was a major hurdle to global state management. But redux introduces its own overhead (Flux architecture, actions and dispatches, etc.) that are unnecessarily complicated for simple state sharing.
I feel like the article spends a lot of time differentiating the specifics of use Context vs state vs reducers, but it kinda misses the bigger point... that using those is often enough and can remove redux, leaving you with more readable and less overengineered code. Redux might be the right choice for really complex states, but it's a pain to work with day to day. Context makes it super simple by comparison.
- that Context doesn't "manage" anything by itself, and definitely not "state"
- That there are significant technical differences between the combo of `useReducer` + `useContext` and Redux/React-Redux, in terms of render performance, data access, and usage patterns.
- That this means there are also different use cases for those tools as well.
I wouldn't use Redux to maintain state for a form or isolated chunk of the app, I'd use context + `useReducer`. On the flip side, if I do have "global" state, I would pretty quickly switch over to putting it in Redux instead.
Your post makes it seem like they are wildly different when in fact they often meet the same need. Use context is helpful precisely because it can replace redux in many situations.
It doesn't really matter how different they are under the hood. Redux is often used only as a global store of state, and context makes that much easier... even globally.
Maybe redux is good for some edge cases, but otherwise it's just overengineered bloat. Context is much more elegant and intuitive. There's no reason to force yourself to use the Flux pattern if you don't have to. I'd certainly never add redux to a project unless I absolutely needed to, it's such a pain...
0 - https://www.quora.com/What-does-the-phrase-Nobody-ever-got-f...
You can't imagine the amount of flak I've taken for that. Managed to get it on a back-of-the-house system, while we built a massively complex React app for the main product. Everyone who worked on it loved it, but was still considered risky. Now that it has a gazillion GH stars and is mentioned in 1 out of 3 blog posts, of course things are much easier.
On the other hand, novelty burnout is a real thing. Javascript has mutated so much in a short period of time that it's become impossible to keep up with -- especially once you factor in frameworks and tooling.
Times like this, I wish vanilla JS/ECMAscript was more powerful out of the box. For a language designed to work with the HTML DOM -- the ONLY language that works natively with it -- it is so woefully underpowered. Why do we need a framework at all to do a simple stateful AJAX UI? =/
For many sites and apps, the business logic SHOULD be the focus of dev time, but it's not... it's implementing trivial business logic inside of the ever-growing monster that is the JS ecosystem. There are 1000 ways to do anything in JS, but never just one good way.
I'm bitter, and I'm not opposed to moving on and learning this stuff, but it's like employers barely understand the value of HTML/CSS relative to how much React is prioritized/used as a single qualifier.
I have "1-2 years experience" with React & friends if that matters, and I consider myself a 10 year Web development vet.
You're lucky that Svelte has taken off but it could have easily been abandoned and you could be stuck with an outdated framework.
Three years ago, someone at my company made the bad call to use Aurelia. It didn't take off, and we are still stuck with this decision.
I'm not claiming that the success is random - Svelte is clearly a far better framework than Aurelia. But the weaknesses often become apparent only later into development, and so it's safer to bet on established approaches.
However I imagine there isn't alot of community libraries to leverage with such a small ecosystem.
Oh, I know people who would. Especially if that choice was made mechanically, without proper assessment of project requirements and framework strengths/weaknesses.
"Nobody ever got fired for choosing IBM/AWS/Google/Microsoft/ESRI" will culturally last a loooooong time (5-10 years? 15?)
"Nobody ever got fired for choosing jQuery? Angular? React? Vue? Svelte? NPM? Yarn? Node? Deno? Next? Gatsby? Netlify? Webpack? Parcel? Babel? Bun? Canvas? WebGL? WASM? Workers? Cloudflare? Fly? Leaflet? OpenLayers? Mapbox?"... that has what, a lifespan of 2-3 years at best?
You're right that this doesn't hold true in a large corporation where they may already have a ton of code and preferred frameworks.
Many types of errors that the equivalent vuejs/react app will show an error page and allow reporting to sentry for will result in an uncatchable halting (some may describe this as "freezing") and with no way to report this to a service like sentry.
This is unacceptable for a framework claiming to be production ready.
It's unclear to me if this has been fixed in the last year or two.
- No one else in the team was familiar with React.
- React did not play nice with the rest of the app and developer work flow.
- It was huge and slow
- He didn't know React as well as he thought he did and we had endless bugs.
- He spent ages working on it.
We rewrote in vanilla JS in 4 days - one dev.
And, yeah, effing JS.
The point is about making safe choices compared to alternatives. Migrating a project without full team buy in and without testing the waters in small incremental experiments is a developer/management problem.
It makes sense for this small website extension because you can build and compile a small component without having to bundle the entire react runtime in.
Fixed.
Supposedly Svelte is able to do this very well, haven't had the chance to try it with D3 myself.
And also the #jobs channel on the Svelte Discord https://svelte.dev/chat
There are jobs being posted every day. And btw, we're one of those looking for Svelte engineers.
[1] https://blog.nativescript.org/perf-metrics-universal-javascr...
Nowhere near enough “to work for large teams”, as is the argument for Angular and the Java world it gets its bad ideas from.
If you hate React for some reason I'd consider SolidJS a much more principled framework.
https://twitter.com/sveltesociety/status/1260209026563858432...
The critical point of adoption is libraries, there must be variety of them to serve broad kind of application. That's "late mover" problem, people are tired of re-implementing stuff again. I wish popular frameworks would pass down some funding to vanilla js libs individuals.
Marketing, it's about image of "facebook's engineering team" vs "these individuals guys". (often time, big corp's team is not that smart, really)
Hiring pool. Small companies couldn't afford shinny things (risks management), so the larger pools of dev, the less risk.
Cult, ahaa.. It seems to LOTs of devs agree that Re*ct sucks. Leaving a cult is not easy, it's leaving community. Most people don't want to leave at all, and in a sense they hate that people are leaving too! They become angry and defensive. So we don't make progress more quickly here.
Working with this framework I found that it was very easy for me to trace back to where the change that caused the error happened.
You don't get this in most frameworks, which hide everything under layers of event handlers, schedulers and whatnot.
Is there a better way, in React or other languages?
I used Vue from 0.12 until around ~2.5, I really liked it at the beginning (coming from a jQuery only world) but I was forced into learning React for React Native and then I kind of standardized on it for a while and Vue fell off.
I used Svelte for a side project recently and it was quite enjoyable but I do really miss JSX and I don't like the $: syntax. I plan to give SolidJS a try on my next side project and then I'll standardize on either Svelte or SolidJS for side projects and React for big things.
Since Svelte and SolidJS are such great options for smaller things I kind of don't have a use case for Vue anymore, but I do remember it fondly.
Want to only allow a specific http method for this route? Have fun adding boilerplate.
Want to throw a specific http error like 403? Have fun writing this by hand.
It also lacks schema validation (I’d love to see ajv here) and openapi gen. You have to write everything. by. yourself.
FastAPI is also great but a little more involved. It's good if you don't want to be in the Django world.
almost with many things in software development to be honest.
In less than a decade, i'm already guessing less than 5 years, WASM will come out with a viable frontend solution that will actually be groundbreaking.
The battles between frontend philosophies in javascript will look like child's play then.
I'm not going to waste anymore time switching FE frameworks (Jquery->Angular->React), as I've found that it's been quite useless (Although I really liked Solid - shame their animation libraries suck and the overall environment isn't mature enough).
I'm happy with React.
Performance isn't an end all be all.
Svelte doesn't have a chance to match the hiring pool of React, nor will Svelte Native ever compete with React Native in maturity.
In 5-7 years, we will be talking about ending the use of Javascript on the Frontend, So i really don't care about reactivity.
The same prediction has been made for the last 25 years. Having seen the rise and fall of VBScript, Flash, Silverlight, Java applets, and countless others, I would not be so blasé as you about the imminent demise of JavaScript. There is a profoundly strong possibility that you are dead wrong.
First of all, I am tired of ridiculous metrics like how small svelte is when it's a really small example, and it's one or two lines of initial boilerplate.
The thing that really set svelte apart was it's better syntax and experience when it first came out. I think that was when react class components, and vue 2 was still prominent. Look at the react and vue 3 examples now. They're really close. Vue 3 in particular looks a lot like svelte with vue's sfc.
I don't even think the dissapearing part about svelte is that important. That kind of performance is rarely going to matter before other bottlenecks. And if it really is that crucial, there's nothing stopping either react or vue 3 from doing something very similar. Vue 3 already has sfc that go through a "compile" process, and it uses getter/setters to make targetted changes.
There's also some considerable challenges to svelte: it's brining in custom syntax to really tackle the problems with reactivity. That's honestly really good if we could get one unifying system. It would be wonderful. But that's a tall order. Given how much traction these other tools already have, I don't see svelte ever fully dominating. Which makes it's extra magic and custom language features even more of a burden. People already complain about vue's few dsl's in the template or react's hooks.
Finally the eco-system for the other tools have come so far. Given how much the gap has closed, and how much farther the other tools are, the better ecosystems make them much better choices. Also as much as I respect Rich Harris, it's a tough sell against people the momentum of something like Facebook or even Evan You with vue and related tools like vite. I know he's working full-time on svelte now at vercel, but the corporate side of this as well as maintaining a community around this is another hurdle. Say wha t you will about react, nobody got fired for choosing it. On the other hand, it's a punch in the gut to jump on something like sapper and then have it be oddly deprecated/rolled into sveltekit.
Now if they make tsx native it'll be game changing
I 100% agree, and I never fully got this argument. But my God do people love to repeat it. So much of react's initial fervor was around "it's just javascript". I write a lot of vue code and I only use like half a dozen directives and learning all of them should take less than one afternoon. And yet, the number of people that don't like vue because of a very simple DSL has been staggering.
It really doesn't make sense to me, but people seem to really hate learning something that superficially looks different.
I also use about 30 different `v-` components from Vuetify, which come with so many properties, events and slots that it might as well be a giant DSL.
There is nothing ridiculous about it. Svelte has a tiny* runtime library by design, so naturally the code output will be much smaller. Also as a result of its design, you do end up writing less lines of code.
> That kind of performance is rarely going to matter before other bottlenecks
It matters a lot for complex apps. React is unoptimized by default, and the standard advice is to only "optimize when you need it", which more often than not is too late. By the time you have an app with 15 context providers and nested components hundred-levels deep, and you start noticing slowness, performance optimization is a gigantic effort.
> it's brining in custom syntax to really tackle the problems with reactivity
While Svelte uses a (tiny) bit of custom syntax, React makes you bring in a ton of DSLs. Hooks, the component lifecycle, and all the third party libraries you will need to build a functional app require a lot more effort. People forget just how much stuff they had to learn.
* fixed from 'no runtime'
I don't disagree with this, but people unfairly complain about it anyway, and it's another roadblock in the adoption process that makes it less exciting to fight for.
> and nested components hundred-levels deep, and you start noticing slowness, performance optimization is a gigantic effort.
That right there is the problem. The DOM is optimized for something like 32 levels of depth which is also the standard used for lighthouse scores. It's always possible to go over that, a little bit, but hundreds? At that point, it's not a question of svelte vs react, but really advanced dom (if even that) manipulation.
Also I found it weird that you mention Evan You WRT vite as a counter to why Rich might be up against stronger devs, but Rich made rollup, which was foundational to Vite's bundling.
Rollup is cool, but it's a very different beast from a f/e framework. For a lot of projects, migrating from rollup to webpack might be a few hours or a week. Migrating from svelte to react, is months if not many man-years.
My point is that you've seemingly taken points away from Rich for the same reasons you're giving Evan You validity.
Migrating between react and vue would take probably the same amount of time -- I'm not really sure what your point is here. My point is that you've unfairly discounted Svelte on the same standards you're raising vue.
I’m not sure what your argument is here, but I’m pretty sure you have it backwards.
The fact that it might take a while to migrate a svelte project to react is not because of poor documentation or tooling or communication or anything like that. It’s because so many things work out of the box in svelte, and to do the same things in react would take tons of boilerplate or third party libraries. Some things may not even be possible to port, at least not easily.
This doesn’t show that svelte is bad though. It shows that react lacks functionality and is more difficult to use.
It matters a lot, especially on mobile phones with less processing power and spotty internet connection.
It's a huge factor, actually. Downloading and parsing React+React-DOM on mobile phones, especially if they are not high end, is miserably slow.
Also, it's not only a user experience problem, your "Google Rank" is influenced by your lighthouse scores.
So I'd argue "that kind of performance" is business critical on several levels. At least in my experience.
However, for any front-end framework, the UI is paramount, and the most full-fledged component framework I found was Carbon Components[0].
I've heard rave reviews about Quasar[1] for Vue 3. Are there any equivalent UI component frameworks for Svelte?
[0]: https://carbondesignsystem.com/developing/frameworks/svelte/
[0]: http://daisyui.com
https://skeleton.brainandbonesllc.com/
https://github.com/Brain-Bones/skeleton
When my partner and I were getting started with Svelte we noticed there was plenty of wrapper libraries, but very few that lean into the benefits of Svelte specifically. We wanted something like Mantine from the React world.
We're still early days (open source and public for about a month) but the feedback has been really positive. The one thing to note is we pair heavily with Tailwind, so if that's not your jam the library may not be for you. However for any sizable app where you're building with a design system, something like this can fit right in.
Hopefully you can give it a try and it helps out! My username is the same on our Discord if you need any help!
This shit right here - {#if <condition>} {:else} {/if} - is why Svelte is deterring me. For the love of god, can we stop coming up with weird custom syntax for templating code? This is one area where Angular also pisses me off: *ngIf for example is just as hideous. With Vue: v-if, v-else. You add it as an attribute to native html, it's dead simple. No weird symbols, no braces or other oddball shit I have to look up when I step away from it for a few months and come back. It just makes sense right away.
Each of them has their upsides but personally I use Vue because it just worksTM. And it has vuex-orm, which albeit not perfect is the only no bs client state orm that you can query any way you like and supports relationships.
I was in an Angular discord and dared speak against the pipes/streams. They has their place but ultimately they're too complicated for every day use. No it's not an issue of me not being able to deal with them. It's a too complicated way. Sometimes all you need is 1 variable, to which the moderators there said I'm doing it wrong, no it's in the data store and I want that 1 var's value, I have to break my fingers just to get it, a block of code to get 1 value, since I can't write if a == 10...
Well they kept suggesting I'm too dumb to handle it and in the end banned me for criticizing their holy framework. I said that I've recently worked with Vue, you have to try other things too, after 3 years of Angular and that Vue was a productivity increase and that I finished 2 projects with vue in the same time I did half a project in Angular.
In the end Vue won it for me, I tried React also NextJS and React has some nice things, it's more JS , more straightforward than Vue but its ecosystem is a hell of commercial offerings. Want to use MUI? Well pay up. Redux-orm complicated because Redux is complicated.
Svelte, I'd love to use it but it's always in development it seems and no "proper" or well maintained packages seem to exist. I did 2 experimental projects with Svelte, it's nice and it's fast but it's never there... always in development
As for React - the Redux alternatives are pretty nice. Recoil, hooks, mobx, etc. are all more friendly.
I noticed that, too. Also, the {#each posts as post} struck me as being different as a fashion statement t. What was wrong with the good ol’ “for item in items” syntax?
Seeing Svelte take the global variables (are they now not global because of Svelte's compiler? probably) in a <script> tag and binding them to HTML elements seems too magic for me. Whereas at least with React, I can sort of understand how it works under the hood and could probably write a poorly optimized version of it without thinking much about it.
React isn't perfect by a long shot so I think something will eventually overtake it, but I hope it's not magic HTML templates, that seems like a step back.
It's a solid pattern that solves a lot of issues in a pragmatic way.
Keep in mind "modern" react is easy less clunky, so the whole state management thing is easier with hooks so it's not as impressive how easy svelte is now at it was when it was introduced 5 years ago.
Oops! One number is wrong in the first column, so you update it, and everything updates automatically. No muss. No fuss.
This is the model that Svelte works in BY DEFAULT. The compiler determines a dependency tree. Variable "b" depends on "a" in a component, you've bound "b" to an element for display, and somewhere, your components logic changes the value to "a". Boom! UI is updated with latest calculation, and all you had to do was use plain ole JavaScript. No useState(). No complete DOM subtree rewrites since the virtual DOM was marked dirty, just the bare minimum of DOM changes automatically.
Reactive variables instead of linking up reactive functions within a reactive framework API.
In React, for performance reasons, you often have to explicitly mark segments of a component (or whole components) that you know won't change so that it doesn't recalculate every time there's a minor property update.
All of that goes away in Svelte. There is no reason to mark segments for no recalculation in Svelte in the first place. It just works, and it just works with what looks to you as the developer as 99% HTML, vanilla JavaScript, and standard CSS.
I imagine most folks who love React syntax have Stockholm Syndrome at this point. Having written for web since 1996 or so, I've seen the progress as well as the fads. I still remember document.write(…) and Netscape's layer tag. I remember the JQuery revolution after the missteps of Prototype. I know full well why React (and Angular and Vue) were created as web sites became larger and more complex.
And I'll tell you truthfully, I haven't been this excited about a return to relative simplicity as evidenced by Svelte in a long time. The strategy behind Svelte is an industry refactor that's been a long time coming. Even if Svelte is not the eventual "winner", I truly hope it's something closer to the Svelte model than the current old guard of Angular, React, and Vue.
You may claim to hate magic, but I have some bad news: there is magic at every level going down to the lightning injected into rock to make it think. The fear of magic is the same argument used by the assembly programmers when C first emerged. "Too much magic. Too easy. Too much loss of control." Never mind that it was an order of magnitude easier to learn, modify, and maintain.
And I'd imagine that most folks who are advocating for Svelte never had to build up a startup before.
If everything was done for performance, then python or ruby wouldn't be used as web server languages today, and yet python and ruby web servers comprise of a significant amount of webservers.
And besides, most performance improvements between React and Svelte are almost invisible to the naked eye, we're talking differences of milliseconds here.
So you've built your web client in Svelte, are you ready to traverse into new frontiers and build a production ready app in Svelte Native?
Or are you going to blow extra capital to hire ios and android developers?
Are you ready to deal with the fact that its not using its own implementation and is using Native Script under the hood?
What about the hiring pool?
Svelte is a great choice for personal projects, but extremely impractical for a startup.
Svelte Native will NEVER reach the maturity that React Native has, and that is what makes react such a practical choice for a startup.
If you had to consult a startup to choose a FE framework for both its web client and mobile client, and you suggested Svelte, I would bet that not only would they lose a lot of capital and time, they would run into so much technical debt.
Svelte for the web client is fine, but now you have to manage a different team for the mobile client.
This is what makes react so strong - the web and mobile clients can be handled by the same team.
React is Practical; it doesn't matter if the philosophy in how they render the dom isn't up to par, the community and the environment around it makes it practical.
And honestly, the performance is good enough.
If Discord can use React + RN, it's good enough for the lion's share of applications out there.
I made the analogy to assembly vs C. It's not about raw speed. Many APIs and (frankly) hacks have been added to React that developers have learned over the course of years. APIs and hacks that simply aren't necessary for Svelte.
I totally agree that the community behind React is absolutely massive. If you want a component for something, chances are someone has made it already. That is a huge advantage. However while the odds are good, the goods are often odd.
When the dev environment is simpler, making the component isn't such a burden. When the code is simpler, maintenance and improvement are easier.
Today, React may be the better choice in many circumstances, and that's fine. However moving forward, expect to see more cases where there's a better option. Because let's face it, Svelte is simply better architecturally. React may be more popular, but you can't argue its foundation is somehow more sound.
I don't agree that they will match React's community and environment in the near future, if at all.
>Svelte is a great choice for personal projects, but extremely impractical for a startup.
> What about the hiring pool?
> Svelte for the web client is fine, but now you have to manage a different team for the mobile client.
These are interesting assertions and run contrary to my experience. I work for a successful startup and our front-end team uses Svelte. We've had nothing but success. We run a production-grade mobile app (Cordova) on old low-powered client-provided devices including RF guns (Android 5 to 9) with multiple thousands of concurrent users in stores/logistics warehouses, and a web app running on desktop (Chrome/Firefox/Safari). And, every front-end developer we have (including myself) learned Svelte on-the-job within a few weeks.
Dude, just use fragments it's just an empty tag in the jsx compiler and adds like zero effort.
Other than that, seems interesting. Didn't actually function in the embedded browser used in my hn client so that's bad... But overall seems like it's worth a try.
Granted, that’s a rather advanced topic, but I miss having a <Component<MyType>> where all the type checking “just works”.
It’s not a dealbreaker - more like just something I noticed coming from the React world.
Couple years ago, there was lot of hiccups especially with TS support or the vscode plugin. It's much better now.
There are some patterns to know to work around some reactivity issues with component reuse but overall, and still some TS issues with vscode (extra warnings due to lack of understanding of component context) but it's still ok.
The biggest drawback of Svelte is not the tech itself, but the lack of a well developed ecosystem of components, design systems, etc. You'll probably end up implementing many components yourself... whether it's a good thing is left for discussion.
I have a lot of experience with React, Vue, and Angular and I have moved completely over to Svelte if the client will allow. Since it uses normal Javascript, normal HTML, and normal CSS it also doesn't seem to suffer as much regarding the ability to find other people to support it. If they can use normal JS, HTML, and CSS the "Svelte" part of it can be learned in a couple of hours max.
Early on, there was a custom component shortage, but it is so easy to wrap plain vanilla JS components in Svelte components that this is has mostly disappeared as well.
If I where going to point out anything negative about it, I would say that if you are used to developing by just plugging in pre-built components (very common in React development) then it won't be as easy.
Svelte has always looked so promising, just what I wanted. But my fear is that if I ditch Vue and jump to Svelte, it will do the same thing as any other framework did: become a monster and cause problems with all my dependencies.
So I'm staying with Vue.
But in hindsight your comment (which could have been mine a few years back!), is really funny. Basically, are you staying with Vue because it's the monster you know, or why don't you fear Vue becoming a monster? :)
I can't claim that that upgrade was painless, it took a few days with an app with > 10 pages, >20 custom components and I had to push ahead with re-writing a 3rd party component or 2 that was only vue 2 at the time (honestly I should never have used them in the first place. reap what you sow). But build times are faster, my bundle size is a lot smaller, I'm really pleased with the new features, and I'm a building faster as a result.
Vue 3 was designed with large complex projects in mind. Vue 2 is probably easier to grok when starting out or for small projects but the functional modularity, typescript integration, and reduced boilerplate with 3 really starts to show in large projects.
I did it slowly over a year and besides having to wait for some dependencies to catch up it was mostly painless.
Although the biggest pain-reduction was getting to use Vite instead of Webpack (shudder). The build tools not sucking is so critical when doing front end dev.
- An SVG-based graph dataset editor: https://codeberg.org/nilesh/grapher
- A curated collection of educational resources: https://github.com/learn-awesome/learndb
Compared to React, developing with Svelte felt like a breath of fresh air.
On the other hand, if you like leveraging most JavaScript features then React, Preact, Inferno, SolidJS and especially Lit are much closer to allowing developers to use any part of the language that is useful, with some exceptions for reactivity.
Lit in particular is 100% JavaScript primitives and very little sugar on top.
Still, it's a great article that does a good job of showing how easy Svelte is. I think it looks most like Vue, but simpler, with even less boilerplate.
Of course keeping everything so simple does make me wonder how it would deal with more complex situations where you really do need a lot more structure.
So has your significant other at the time you introduce them to your family, right?
In my personal experience I spend less time creating the web front ends this way comparatively to when using "frameworks". No "compiling" is needed either, other then optional minimization.
Let's have a look at this "compiled" JS. Here's an snippet from the volume slider in his example:
function b() { v = W4(this.value), h(0, v) }
I understand that this is "compiled" - but really it's not - it's EcmaScript. If I wrote code like that, I'd get fired.
You can see the compiler output in the "JS output" tab here, it's very easy to follow: https://svelte.dev/repl/12aefec27f0d4ec5ad85ab7e5a123642?ver...
Just make sure that overall architecture and process enforced and are designed by experienced person/s rather than hamsters.
I'm really looking forward to the stable release of SvelteKit to use as the backend for my next project.
I'll habe to check this combination put however. Now the price question, did you use an oidc client? If so which works with both app and web?
Phoenix overtakes Svelte’s spot as the most loved web framework.
React.js completes its fifth year as most wanted.
So I’m not sure that’s an unequivocal “yes”.
However, I'd like to add one more reason to the "arguments adopting svelte" and that is native development.
Svelte Native doesn't even come close to touching React Native in maturity, and I'm willing to bet it never will.
For a startup to consider a frontend technology, React is easily the better choice in terms of capital because there is no way you're going to build a production ready native app in Svelte Native.
If you were to build your web client in Svelte, then you would have to spend capital on another team to build Native (God forbid in React Native), in which you would split teams on ios and android.
Or you could you use just one team for React + RN altogether and save you possibly millions in capital.
Also I'd like to mention that the NYT article that was linked to showcase Svelete actually showcases more of D3 instead.
Mike Bostock also used to work for NYT and NYT absolutely loves using D3.
Maybe it's finally time for someone to standardize this - even if just pointing at what vue & svelte already do - so every tooling can go ahead and support amalgams of filetypes in a single file for any framework that wants to work like this.
It's a wonder how react managed to force their jsx and angular forced annotations into typescript just to get a good typescript experience out of the box.
Mixing languages/dsls in a single file shouldn't be a problem.
Should also work for things like in-line sql fragments for orms etc?
this is such a common misconception i feel like we should put this in the FAQ somewhere. people are fixating on the wrong thing when they go “oh ho 2 way binding bad”. its local and its compiled away, its fine.
https://twitter.com/rich_harris/status/1420214295242199041?s...
https://twitter.com/rich_harris/status/1147902393293688834?s...
Svelte is a compiler which strip unnessesary JS code in the output.
Wish: Combine both, don't compare.
I'm extremely biased towards react due to the fact that it effectively brings very strongly typed templates/components to the table, which has saved me easily a hundred hours of debugging/testing over the last 4 years. It also makes components MUCH more accessible due to the declarative nature of props (and their respective types).
I liked working with it, but I regret not waiting for 1.0 to really dive in. The breaking changes are getting annoying, with the most annoying being recently with changes to its routing. It seems like every time I make a small change and go to rebuild my sites, I'm dealing with a new headache.
Don't get me wrong, the changes are probably warranted to avoid Angular-style major version catastrophes, but for me, the draw to svelte is its ease of use. If I can't go a day without having to go digging for a fix to a breaking change, it's really not that easy to use. I'm mostly a hobbyist dev and don't have the time to keep up with it.
Also, the new folder-based routing is clunky as hell. I'll probably spend some time learning Next.js for future projects. Its ecosystem most likely trumps the syntactic supremacy of svelte currently. That said, I don't doubt svelte will introduce something that reels me back in again in the future.
I don't need it. Only seems to bring SSR which many projects simply don't need.
Svelte and vite are working fine for me.
My current project is tied for the most complicated front end project I've built.
It's offline first, pwa, service workers, indexeddb, etc etc. No problems so far. Could use better documentation but what projects can't.
It's been great.
I have no experience with Vue, but I'd rather not work more with react.
You can even add a line that just says `myVar;` and the reactive block containing it will be executed on every `myVar = ...`.
I think svelte has taken the best part of the rxjs observable pattern without the PhD level of insanity in the reactive frameworks.
Beyond debouncing and throttling, the uses for rxjs style reactive patterns (all the variations of Subjects) gets super confusing fast. (Look at a moderate sized Angular app and you see the horror of types and brackets needed to handle http calls and errors correctly, for example).
i'm not that bothered about the various technical trade-offs, i mean they sent a rocket to the moon using assembly language
i just want to know how {newThing} can help me get shit done at work faster with less headaches.
Svelte is currently version 3.5
Something's changed, but the syntax and the svelte way of doing reactive components is the same (but I only used version 3, don't know how they did in the previous versions).
SvelteKit on the other hand is still very much a work in progress. I'm using it for personal projects and it's great, but I'm surely waiting until v1.0 to do anything serious with it.
Can you elaborate on what you mean by this?
Angular: use inbuilt router and rxjs
Vue: use vue router and pinia
React: shop around third party libraries.
You can shop for alternatives for both angular and vue as well, but they have a first party solution. While react does not and will not have a first party solution for this and many other use cases