Mobile - - By Clay Unicorn

Server-Side Swift: Comparing Vapor and Perfect

One of the reasons Swift has become a major player in web development is that there is a variety of great quality frameworks to build web apps. Not all frameworks are created equal, and not all frameworks feel equal. My goal here to compare Perfect and Vapor in terms of their popularity, ease-of-use, features, and community; in order to help you decide which framework is right for you.

Backgrounds of Perfect and Vapor Frameworks

Vapor has the private backing of a consultancy and Perfect raised $1.5 million in seed funding last year. With the social foothold that Perfect has both in seniority and numbers, one could say that it’s the most popular. Then again, Vapor released version 1 in September of 2016 (four months old at the time of this publication) and has risen in popularity to nearly match Perfect in stars and public activity. Popularity is hard to quantify, so here are the facts as of March 2017, and I’ll let you decide:

Perfect

  • Has more stars on GitHub (~25% more)
  • Way more followers on twitter (~41k to ~1.4k)
  • Perfect has been around longer (October 2016)
  • Because there is less noise in Slack, the core team is responsive to questions

Vapor

  • Has more users on Slack (almost double)
  • More contributors than Perfect (71 vs 36)
  • More activity in Slack channels

Community Vibe

For me, one of the biggest metrics I use to weigh in on the viability of any tech is the culture of the people that are building it. If you analyze the community behind any company or tech project, you will find a common trend: transparent and kind communities succeed over closed and abrasive ones. I decided to join the Slacks of both Vapor and Perfect anded engaged in coversation. What I discovered was a less experienced but open community around Vapor, and a senior but elitist community around Perfect.

The Vapor Community: Vibrant, Kind and Transparent

Open Source Software (OSS) relies on open collaboration, and Vapor has the best culture of any Swift framework on this front. The framework is licensed as MIT, which is one of the most generous and open licenses that one can assign to their project. They also support a public roadmap via milestones and issues on GitHub. Both of these points allow for rapid feedback loops and iterations from the community.

The recurring theme I picked up on was that Vapor was a “fun” community to be a part of. With active open issues and pull requests on GitHub, it’s obvious that Vapor cares about including ideas and opinions of the community at large. I talked for a while with Joannis, Matt, and Tim who candidly shared their thoughts and opinions. Joannis had great points to make about the framework and its future, and showed dedication and care for the community. If these people are an accurate sampling of the Vapor community as a whole, it bodes well for a healthy future for the framework. I’ve edited and redacted the original transcripts, for clarity:

Vapor developers and community are very open. Testing and docs are top-notch. Type safety, obviously, is a big part of Vapor. They do that brilliantly; better than any other web framework and even most, if not all, libraries. Vapor has some other really good parts, like the API. I think everyone who was really involved with the SwiftX project a year ago is into this modularity. That’s a really positive point here.

— Joannis

The Vapor community prides itself on culture, collaboration and modularity. Vapor comes out of the box with all the tools necessary to build most typical web applications. This supports Rapid Application Development (or “RAD”) a concept tokened by the Rails community. RAD is a belief that there is a right and easy way to scaling web applications; a framework should be opinionated in convention and features to help developers quickly and safely create rich applications. The RAD principle has been adopted by Laravel, Django, and Vapor.

I love how easy it is to write a provider or extend the framework. The community here make awesome work for packages.

— Matthias Ludwig

The Perfect Community: Experienced, Mature, Versatile

I must admit, that at the beginning of my research, I had grown a bit biased against Perfect due to some unsavory comments on reddit. While there does seem to be some lingering competition and heated dispositions still within the Perfect community, the founders were mostly neutral, knowledgeable and forthcoming. The tension between the communities in the past seemed to have died down and there seems to be some mutual respect on both sides now.

I think that Perfect starts out slim and you add components to it as you build & that Vapor start out much larger and you need to strip things you aren’t using out (if you’re concerned about bloatyness). At least that’s my take away from what I’ve seen with [Vapor]. These could be pro or con depending on what you’re looking for.

— Kyle Jessup

The founders of Perfect were very terse when sharing any downsides to the framework. The team also took issue with developers drawing parallels to Vapor. Overall, I felt like I was in a chatroom thick with ego. To say whether ego is good or bad is a matter of perspective.

A quirk of the Perfect community is that they don’t use GitHub issues to track bugs or feature requests. Deep down in their readme they reveal that they favor JIRA, which requires you you to create a separate account. Yet despite lacking publicly trackable issues, they did share an openness to pull requests and collaboration via their dedicated Slack room.

[We’re] totally open to public contributions and feedback

— Jonathan

What I came to realize was that there are extremists in every community, and that their views and opinions do not necessarily reflect the whole. In some of my conversations, I did find a bit more hostility towards Vapor from Perfect developers while the other tribe seemed more polite. Yet the Perfect community might be somewhat justified. Egos abound in other communities and a lot of it comes down to experience.

Familiarity and Ease of Use

Hello Worlds

Here’s what a “Hello, World” Vapor application can look like:

let drop = Droplet()

drop.get("hello") { request in
    return "Hello, world!"
}

I found the API of Vapor to be very expressive and succinct, while abstracting a lot.

Here is a sample “Hello, World” built on Perfect:

var routes = Routes()
routes.add(method: .get, uris: ["/"], handler: indexHandler)

func indexHandler(request: HTTPRequest, _ response: HTTPResponse) {
  response.appendBody(string: "Hello world")
  response.completed()
}

First steps

When dealing with any new framework, I think the greatest barrier to entry is installation and configuration time. If the process for building an application requires a lot of steps, then you may be too frustrated to proceed any further. Both Vapor and Perfect have rich documentation and examples. Furthermore, the setup process for both frameworks was “easy” depending on your perspective.

To very junior web developers, Perfect will probably feel more intuitive. The Perfect Assistant will let you click your way through installation, setup and deployment. If this is your cup of tea, then you should feel at home with a full GUI.

If you have worked on the web with other frameworks, than Vapor is probably the framework you will enjoy the most. It feels very similar to other popular web frameworks, and comes with a CLI tool to make system tasks very simple and easy.

Screenshot of the Perfect Assistant

From both perspectives, Perfect gets an “A” for effort for their development of the Perfect Assistant. The assistant is a native macOS app that allows you to create and build a new project from a GUI. They have included boilerplate templates for you to start scaffolding from, and handle most of the installation and configuration for you. This level of maturity in setup is rare for a new framework. I applaud their efforts in making Perfect easy to jump into.

Screenshot of the Vapor Toolbox

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. Vapor built a CLI program 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 with Vapor. I was up and running with three copy/paste steps from Vapor’s documentation, and each step was elegant and simple. If I have to pick a winner based on my own experiences in teaching and building, the clear winner to me is Vapor.

Benchmarks

When it comes to benchmarks, a wider gap starts to show between Perfect and Vapor. 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 refined as much as possible, then the modules that extend that framework will start to compound performance issues. Ryan Collins carried out some great research comparing the performance of Perfect and Vapor on macOS and Linux.

Ryan reports that Perfect outperforms Vapor on Mac on nearly every front. Perfect has better build times, memory usage, thread usage, requests/second and latency.

Wrapping Up

At a high level, I can conclude the following: Vapor is best for rapid application development and Perfect is best for building perfoment applications. Both frameworks are nearly evenly matched on most qualitative fronts: popularity, community backing, and commitment to “winning” the future of server-side Swift.

Further Reading and Sources

Sponsors