A Svelte New World

a Svelte New World

By Lorenzo Fontana

Both Mastiff 2 and Forge 2 will undergo a major reengineering of the front end. While we are not rewriting the composer (at least for now), everything else will become more modern, easier to maintain, modular, and capable of being packaged both as a Web and Electron application.

I unavoidably needed to abandon the UI-framework-free approach that is characteristic of the API Fortress front-end, and embrace the right UI framework. As you probably know, the UI framework marketplace is crazy – different philosophies, different approaches, and completely different strengths and weaknesses. Choosing the right UI framework can be a head-spinning decision, because once it’s done, there’s really no turning back. Fortunately, I knew exactly what key features I was looking for so I could at least shrink the search.

Use React! That’s what many of my friends told me. Not so fast. Just because something is popular, doesn’t mean you must go for it. You might miss out on finding something that is more suitable to your unique needs. Six years ago, I decided to dismiss the popular frameworks, Angular and React. Sure, these frameworks have built good track records, but my reasons for dismissing them six years ago still exist today.

I needed something that not only would allow me to write a good piece of complex software, but that could really help me in a moment of need. What I really wanted was something that offered an intuitive, effective, and repeatable workflow that would avoid piling up boilerplate by reducing the amount of code needed, instead of increasing it.

When you have a battalion of developers, all you need to care about is whether the framework reliably does what it’s supposed to do, but when your resources are limited, you need to make sure that the framework will drastically reduce the number of days you hate yourself.

Rich HarrisSvelte surprised me immediately.

Svelte is a fully reactive (as in “reactive programming“) UI framework with a mission statement that could be simply summarized as – no bullshit. Actually, it is hard to categorize Svelte as a UI framework at all. Svelte is more like a powerful reactive UI development library. You “use” Svelte, you don’t “adopt” it. The main aim of Svelte is not to control your webapp with a ton of functionalities and philosophies you didn’t ask for; rather Svelte gives you the building blocks to create powerful UIs. As a free thinker, as you may have guessed by my previous statements, I don’t let anyone tell me what I should think, let alone a piece of JavaScript.

Svelte’s syntax is compact, extremely readable and remarkably effective (again, no bullshit) to the point that I can show a snippet to my CTO (a strictly back-end engineer) and not see him puke all over the office.

The boilerplate is simply non-existent, and by that, I mean you don’t need to write specific code to make it work. The only code you need is the code that effectively does something – your business logic, so to speak. If you’re a React developer, I invite you to have a look at these examples and then go cry in your safe space.

Finally, Svelte’s performance is shockingly good. Now, this area wasn’t at the top of my list of needs. Pre-optimization = bad. However, I realized that seasoned API Fortress users are used to high performance, and a step back in this area in any context is not desirable. So this framework’s surprising performance is a very pleasant discovery. Check out this nice lecture to learn more.

Of course, I didn’t become a Svelte champion without proof that Svelte was what I wanted. I’m an evidence-based carbon unit, and I needed to validate my hypothesis. In my spare time, I created a whole standalone, fully functional project to make sure that not only could I use Svelte, but that I could also overcome any unexpected issues. Although this project had its gotcha moments for sure, I was able to complete the project with a fraction of the pain and effort that I had been prepared to endure. In fact, the largest problems I encountered were related to the abilities of other tools, such as UI kits that needed to be directed effectively by Svelte. This was not surprising given its young age and lack of explicit integrations.

In conclusion, Svelte is now a key component of my tooling and the API Fortress that is upcoming. I strongly recommend you to at least give it a look, and regardless of whether you’ll include it in your rack or not, I think there’s a lot to learn from the way it was engineered.

API Fortress is a small team of dedicated people trying to deliver the best experience possible for automated API testing and monitoring across entire organizations. It may sound like a marketing pitch, but it pretty much describes what the company has been trying to do since its inception.