Server-Side Swift: Comparing Vapor and Perfect

Share this article

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

Frequently Asked Questions on Server-Side Swift: Comparing Vapor and Perfect

What are the key differences between Vapor and Perfect in server-side Swift?

Vapor and Perfect are both popular frameworks for server-side Swift. However, they have some key differences. Vapor is known for its simplicity and ease of use. It has a more intuitive API and a more active community, which means you can often find solutions to common problems more easily. On the other hand, Perfect is known for its performance and robustness. It has a more complex API, but it offers more control and flexibility. It’s also more mature and has been around longer than Vapor, which means it has more features and is more stable.

How does the performance of Vapor compare to Perfect?

In terms of performance, Perfect generally has the edge over Vapor. It’s designed to be highly efficient and can handle a large number of requests per second. However, Vapor is not far behind and its performance is more than adequate for most applications. It’s also worth noting that the performance difference between the two frameworks is often negligible in real-world applications.

How easy is it to get started with Vapor and Perfect?

Both Vapor and Perfect have good documentation and plenty of resources to help you get started. However, Vapor is generally considered easier to learn and use, especially for beginners. It has a more intuitive API and a more active community, which can be a big help when you’re just starting out. Perfect, on the other hand, has a steeper learning curve, but it offers more control and flexibility.

What kind of support is available for Vapor and Perfect?

Both Vapor and Perfect have active communities and plenty of resources available online. Vapor has a more active community, with a large number of contributors and regular updates. Perfect, on the other hand, has a smaller but still active community. Both frameworks also have good documentation and plenty of tutorials and guides available.

Can I use Vapor and Perfect for large-scale applications?

Yes, both Vapor and Perfect are capable of handling large-scale applications. Perfect is known for its robustness and high performance, making it a good choice for large-scale applications. Vapor, while not quite as performant, is still more than capable of handling large-scale applications, and its simplicity and ease of use can make it a good choice for large projects.

How does the development experience compare between Vapor and Perfect?

The development experience can vary depending on your personal preferences and experience. Vapor is generally considered easier to use and more intuitive, making it a good choice for beginners or those who prefer a simpler development experience. Perfect, on the other hand, offers more control and flexibility, which can be appealing to more experienced developers.

What are the system requirements for Vapor and Perfect?

Both Vapor and Perfect can run on macOS, Linux, and Windows. They both require Swift 5.0 or later, and they both support the latest versions of Swift. They also both require a compatible version of the Swift Package Manager.

How do Vapor and Perfect handle database integration?

Both Vapor and Perfect offer support for a variety of databases, including MySQL, PostgreSQL, and SQLite. They both provide ORM (Object-Relational Mapping) tools to simplify database operations. However, Vapor’s Fluent ORM is generally considered more intuitive and easier to use than Perfect’s ORM.

What kind of applications can I build with Vapor and Perfect?

You can build a wide range of applications with both Vapor and Perfect. This includes web applications, APIs, microservices, and more. Both frameworks are highly versatile and can be used for a wide range of projects.

How do Vapor and Perfect handle security?

Both Vapor and Perfect take security seriously and provide a range of features to help protect your applications. This includes support for HTTPS, secure cookies, CSRF protection, and more. However, as with any framework, the security of your application will also depend on how you use it and the security practices you follow.

Clay UnicornClay Unicorn
View Author

Clay is a tech consultant by day and hacker by night. He's launched dozens of mobile/web/IoT applications for companies like Pepsi, Samsung, and Red Bull. He loves teaching more than anything, and is always happy to help!

perfectserverswiftvapor
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week