Getting Started with Server-Side Swift Using the Vapor Web Framework

Ever since Apple open-sourced Swift, the developer community saw a greater potential for the language than mere client-side iOS development. That community envisioned a language that could become more universal and cross-platform, as evidenced by the emergence of server-side Swift powered by the Vapor Web Framework.

Why code your back-end in Swift?

One of the most burning of questions is, "Why have Swift on the server in the first place?" True, we already have great and well-established server frameworks out there, like Node.js and Rails, so why invest in a platform that may not be as mature as those other platforms? You get a lot of added benefits, for starters.

Leveraging the same technology on your backend as on the iOS client means you can use the same team on both ends, adding greater knowledge transfer and knowledge redundancy and lowering cost-of-maintenance through additional resources.

Having a Swift back-end and front-end means that you can divide feature development according to features instead of technology stack. While one developer will own the entire registration process, another developer owns the entire activity feed feature—that is, you get vertical rather than horizontal delegation and ownership.

Swift has amazing potential on the server, and to be an even better language for server-side development Swift needs great low-level APIs common among server frameworks. The Server APIs project will provide core capabilities in areas such as networking and security, so Swift programs no longer need to rely on platform-specific C libraries frequently to provide this functionality. As a result, developers will be able to create frameworks and server applications using pure-Swift code, without the need to also have systems programming skills and knowledge of multiple platforms. (Source: Swift.org)

Getting Started with Server-Side Swift, Using Vapor

While it's still early days for server-side Swift technology, Vapor is actually one of three emergent server-side Swift frameworks, with the others being Perfect and Kitura. Perfect was one of the first Web server toolkits for Swift, and Kitura (as featured during an Apple 2016 WWDC Server session) is backed by IBM. My framework of choice for this tutorial is Vapor.

Vapor is a modern server-side platform using HTTP or Web Sockets with some claiming that it is almost 100 times faster than other comparable Web frameworks, such as Ruby and PHP. 

Read the rest of my article, exclusively on ProgrammableWeb