Svelte and the Future of Frontend Development
First released in 2016, the Svelte web framework has steadily gained popularity as an alternative approach to building web applications, one that prides itself on being more intuitive (and less verbose) than the current framework du jour, Facebook’s React. You can say that it reaches back to the era before the web app — when desktop and server applications were compiled — to make the web app easier to develop and more enjoyable for users.
In this latest episode of The New Stack Makers podcast, we interview the creator of Svelte himself, Rich Harris. Harris started out not as a web developer, but as a journalist who created the framework to do immersive web journalism. So we were interested in that.
In addition to delving into history, we also discussed the current landscape of web frameworks, the web’s Document Object Model, the way React.js updates variables, the value of TypeScript, and the importance of SvelteKit. We also chatted about why Vercel, where Harris now works maintaining Svelte, wants to make a home for Svelte.
TNS Editor-in-Chief Joab Jackson hosted this conversation.
Below are a few excerpts from our conversation, edited for brevity and clarity. But you really should listen to the whole conversation here:
Svelte and the Future of Front-end Development
So set the stage for us. What was the point that inspired you to create Svelte?
And to me, this felt like the future of journalism, it’s something that was using the full power of the web platform as a storytelling medium in a way that just hadn’t been done before. And I was very excited about all that, and I wanted a piece of it.
And so I started building a toolkit, really, for myself. And this was a project called Reactive, short for interactive, something out of a Neal Stephenson book, in fact, and it actually got a little bit of traction, not that it was never huge, but you know, it was my first foray into open source, and it got used in a few different places.
And I maintained that for some years, and eventually, I left that company and joined the Guardian in the U.K. And we used Reactive to build interactive pieces of journalism there, I transferred to the U.S. to continue at the Guardian in New York. And we used Reactive quite heavily there as well. After a while, though, it became apparent that, you know, as with many frameworks of that era, it had certain flaws.
A lot of these frameworks were built for an era in which desktop computing was prevalent. And we were now in firmly in this age of mobile-first, web development. And these frameworks weren’t really up to the task, primarily because they were just too big, they were too big, and they were too bulky and they were too slow.
And so in 2016, I started working on what was essentially a successor to that project. And we chose the name Svelte because it has all the right connotations. It’s elegant, it’s sophisticated. And the idea was to basically provide the same kind of development experience that people were used to, but change what translated into the experience end users have when they run it in the browser.
Can you talk a bit more about the compiler aspect? How does that work with a web application or web page?
Svelte seemed to take off right around the time we heard complaints about Angular.js. Did the frustrations around Angular help the adoption of Svelte?
Svelte hasn’t been a replacement for Angular because Angular is a full-featured framework. It wants to own the entirety of your web application, whereas Svelte is really just a component framework.
So on the spectrum, you have things that are very focused on individual components like React and Vue.js and Svelte. And then at the other end of the spectrum, you have frameworks like Angular, and Ember. And historically, you had to do the work of taking your component framework and figuring out how to build the rest of the application unless you were using one of these full-featured frameworks.
Nowadays, that’s less true because we have things like Next.js, and remix-vue, And on the Svelte team we’re currently working on SvelteKit, which is the answer to that question of how do I actually build an app with this?
I would attribute the growth in popularity is felt to different forces. Essentially, what happened is it trundled along with a small but dedicated user base for a few years. And then in 2019, we released version three of the framework, which really rethought the authoring experience, the syntax that you use to write components and the APIs that are available.
Around that time, I gave a couple of conference talks around it. And that’s when it really started to pick up steam. Now, of course, we’re growing very rapidly. And we’re consistently at the top of developer-happiness surveys. And so now, like a lot of people are aware of is, but we’re still like a very tiny framework, compared to the big dogs like React and Vue.
You have said that part of the Svelte mission has been to make web development fun. What are some of Svelte’s attributes that make it less aggravating for the developer?
The first thing is that you can write a lot less code. If you’re using Svelte, then you can express the same concepts with typically about 40% less code. There’s just a lot less ceremony, a lot less boilerplate.