Swift Web Frameworks: Vapor vs Perfect

Become a Subscriber

When web frameworks first emerge, it can be difficult to decide which will stand the test of time, and which ones will fade away. Swift is no doubt already a mature language. With a solid two years in production with iOS applications, the language has already seen three version releases and has full buy-in from Apple. Yet the frameworks have a lot of catch up to do. Frameworks built on older languages like Rails, Spring, .Net, etc have been around for years. Some of them going on decades. These web frameworks have a lot of strength in their old age, and have benefited from even older languages under the hood. But we accept the swift is the new kid on the block. What it lacks in maturity, it makes up for with ingenuity.

I explored the two most popular Swift frameworks for web, and wanted to share our experience with both. If treat frameworks like stock options, I want to know which one’s are worth investing in both for long term viability and growth and success. Since this is hard to define with qualitative data alone, I decided to enlist the help of other developers that are both well versed in web frameworks along with the Swift language. Hopefully, this approach is well received, but I would love to have feedback based on your own experiences.

Both frameworks are nearly evenly matched on most non-quantitative fronts: popularity, community backing, and passion for “winning” the future of server side swift. TL;DR: If you like strong conventions and the “fun” of open source, Vapor is the best. If you’re a hacker and want something flexible and all-inclusive, then you may want to use Perfect. If I personally had to choose a side, assuming you care about such a thing, then I would go with vapor. The vapor community seems more open and collaborative than perfect, and the framework and ecosystem feels right to me.

Evaluating the community

For me, one of the biggest metrics I use to weigh in on the future success and viability of any tech is the culture of the people that are building it. If you analyze the brains behind any company or tech project, you will find a common trend: transparent and kind communities succeed over closed and abrasive ones. As I was combing reddit and slack communities to learn more about the communities that back these frameworks, I found a clear and common trend: followers of perfect seemed smug and hostile and vapor fans were more humble and social. The interviews I conducted with members of these communities reflected the same results. I told you this would be an opinion piece, but I have no motive or bias. The Perfect developers might be right, and I have seen egos in other communities, and at times they were somewhat justified.

Quantifying sentiment of an entire community is a difficult task. Some of the opinions I formed were due to reddit, slack conversations, and forums.

“Perfect is amazing. […] Are you a novice developer? […] Reading your comment history, you seem more like a Vapor fanboy (or author?) looking to piss on another great project and get people to join your "kewl kids club”. […] Keep your high-school clique-making to yourself.“ source

This ego and conflict is obvious throughout a couple reddit threads and reference more bullying on Perfect’s github issues page. Since then the Perfect team removed support for issues on the repo. The fact that Perfect closed support for issues, is a problem by itself. "Open source” tends to be synonymous with open communities. Perfect is in a small minority of github repos that has closed off community feedback. This is not conducive to building a collaborative community and goes against everything OSS is all about.

On the other side, the vapor developers I talked to were insightful and much kinder. When directly asked to compare and contrast Perfect vs Vapor, not a single person said anything negative about Perfect to justify their points in preferring Vapor.

Things I like very much about Vapor as opposed to Kitura/Perfect: the ‘batteries included’ approach, with an ORM, a hasher, authentication, a client for third-party APIs; the way the core developers are open to entertaining ideas and accepting PRs from the community, pretty much anyone with a good idea is encouraged to contribute; and as a result of that, the Slack community is so friendly and helpful, even to complete beginners. It’s a positive community, there’s almost never a complaint. - Toby Griffin

The proof is out there, and I’ll refrain from getting too opinionated on this front. In short, it seems the Vapor community is better than Perfect community.

Ease of Getting started

When dealing with any new framework, I think the greatest barrier to entry is setup time. If the process for building an application requires a lot of steps, then you may be too frustrated to proceed any further. Both of these frameworks have rich documentation and examples. Furthermore, the setup process for both frameworks was “easy” depending on your perspective. Perfect seems to cater towards inexperienced developers while vapor seems to follow conventions seen in other frameworks. Having taught hundreds of developers over the years, I feel well equipped to asses this from both a veteran programmers point of view as well as a novice’s.

From both perspectives, Perfect gets an “A” for effort in developing the Perfect Assistant. The assistant is a native mac app that allows you to build a new project from a GUI. What is most impressive is the automated installation and configuration of docker, Xcode, and other dependencies. They have also included boilerplate templates for you to start scaffolding from. This level of maturity in setup and configuration is rare for a new framework. I applaud their efforts in making Perfect easy to jump into. The concern with this approach is the abstraction itself. GUI’s are great for users, but as engineers, we should be accountable to know what is going on under the hood. With Perfect your options seem to be: click your way through setup or build everything by hand. Warning: strong opinions follow. I would never teach a new developer by having them use GUI tools. While they have their place, I think an app-based approached to interacting with code should be a luxury and reward after having mastered command line. Thus, if you were going to learn Perfect, you should start by building from scratch and understand that process before leveraging an app which manages the process for you.

Vapor is not far behind in their ease of setup. One might argue that for a more experienced developer, their process is even better. Most senior developers prefer to build through command line. This allows you to watch the build process and is more conducive to learning the inner workings of the underlying components. Popular tech such as heroku, rails, and docker provide developers some sort of command line toolbelt. Vapor followed this mantra and built a toolbelt to install, setup and manage projects. Despite the fact that Perfect has a nice GUI assistant, the initial process of installing and launching a “hello world” application actually took much longer than Vapor. I was up and running with three copy/paste steps from their documentation and each step was elegant and simple. Mind you, I’m comfortable with shell and understand what “magic” is happening under the hood, but so do most web developers coming from another language or framework.

Again, if I have to pick a winner based on my own experiences in teaching and building, the clear winner to me is Vapor. I swear, I’m not biased.

Benchmarks

When it comes to benchmarks, a wider gap starts to show between Perfect and Vapor. Benchmarks are most important in the second or third major iterations of a framework. They may reveal shortcomings at the core which may prove problematic in production. Akin to kernel hardening, if the core of a framework isn’t perfected as much as possible, than the modules that extend that framework will start to compound performance issues. Ryan Collins wrote a great article comparing Perfect and Vapor (among others) and the results are conclusive: Perfect outperforms Vapor in almost every test.

Why does this matter? Rails is one of the most respected and well known web frameworks. It has been a historical choice of a significant tech companies such as twitter, airbnb, github and more. Despite being well-liked and respected for it’s ease-of-use and conventions, the framework has suffered from performance issues which have tarnished it’s reputation. Even if Vapor dominates over Perfect in every other way, it may suffer a short life if adoption drops off due to performance issues in production. All it takes for a framework to lose credibility is a successful tech company trashing it publicly. Twitter did this with Rails, Facebook did it with web apps on mobile, and the list goes on. Entire frameworks and companies have thrived or died based upon their reliability, and if there is one measure of the future success of a framework, this is it.

Wrapping Up

Both frameworks have a fighting chance to “win.” They are young, unused in large production applications, and have time to evolve. If you care about my opinion: I think that Vapor will beat Perfect in the next year. Out of the two, Vapor follows more typical developer conventions which will attract more talent to their framework. This community has also proven to be more open and collaborative, which is crucial for open source software. They have also committed to joining in the Open Swift initiative, which aims to create conventions that all Swift projects should follow. When I think about this, what comes to mind is Rack and w3c which have unified and been instrumental in the success or failures of other frameworks and languages over the years. In choosing to join these communities and commit to their standards, Vapor is making a choice towards a better future of server-side swift, a choice that may make them victors. Vapor needs to resolve performance issues in coming months, but if they can attract the right talent, then they stand a good chance of doing so, and in being the next big name in web.