I am stil trying to catch up with all those WWDC 2016 videos. Admittedly, I had to watch a few of them twice. Partly because some of them are so interesting and partly because some of them are really hard to understand the first time you see them. The video about server side Swift definetely belongs to the former group. I was really impressed by IBM's Kitura and their cloud tools for Swift. That's why I'd like to talk in this week's blog entry about my first impressions I had with Kitura and Vapor, another Swift web framework.
My personal goal with both frameworks was to get my Swift web app running on Heroku. You can find a nice tutorial about this with Vapor here. For a quick primer about this with Kitura, you have to watch the WWDC video I mentioned above.
No matter which framework you choose, they more or less have the same premises. First and foremost familiarity with the Swift compiler on the the command line. Depending on which frameworks you choose, it probably needs a compiler version you don't have yet installed on your system. To make this easier, I recommend Kyle Fuller's swiftenv which helps with installing and selecting Swift compiler versions. Then, if you haven't already, you need to get some basic understanding with the Swift package manager and its configuration file. The file itself is pure Swift, which makes it really easy to understand. Last but not least, you need to learn some basics about Heroku, on which the web apps are running on. Since server side Swift is still so new, Heroku doesn't support it by default. But with Kyle's buildpack it's no problem at all.
Having said this, let me talk a little about each web framework individually.
As I said before, what was shown in the WWDC video 415 was very impressive. Add on top the good community support and IBM's own interest to make it successful and you've got the right ingredients for an excellent web framework. Its syntax is concise and elegant and the documentation is examplary. I honestly enjoyed dipping my toes into this new Swift API.
Although I didn't have any problem running my local Kitura web app, I ran into a few problems pushing it to Heroku. Swift can't resolve any lib dispatch references in Heroku's compile phase. This makes sense since Kitura documentation clearly states that lib dispatch requires an additional installation step running on Ubuntu which is used for Heroku's dynos. I am optimistic I can resolve this by customizing the buildback, although it requires me learning a little bit more about buildpacks in generalfirst.
Vapor's API syntax isn't that far from Kitura's which was the main reason I started playing around with it. The API documentation is excellent and the overall support from the community is strong. Having no problem at all deploying it to Heroku, made me enjoy it a little more than Kitura. I mean, Swift running on a remote Server ... How cool is that?
Vapor like Kitura is of course still in the early development stage. But nonetheless you can already achieve quite a lot with it. There are of course a few problems. Right now it's lacking Postgres support which is kind of a bummer when it comes to Heroku, Apart from that there currently are some problems with its template library Mustache, which seems to have a few Swift compiler issues. But as I said, Vapor is still young and those problems are stereotypical for an API in its early stages.
Server side Swift is not yet ready for production use. But look how far Swift has come in just 2 years. We have reached a major milestone with Swift 3.0 and from here on we won't see so many code breaking changes as before, which.is by the way exactly the problem Kitura and Vapor were facing for months now. Once their sources had been adapted to the current state of Swift 3 they became dependent on the Swift compiler supporting that very state. With Swift 3 being officially released in a few months, we are going to have several mature Swift web frameworks soon at our disposal. It's so great to see in which direction Swift is moving. Mobile Apps, Desktop Apps, Web Apps ... There are literally no limits. Exciting times.