Swift is mostly known nowadays as the main programming language you can use to develop on Apple devices. However Swift, being Open Source, has a small community of dedicated people that have started to work on building an ecosystem to make Swift development on the server-side a viable option.
Swift Server-Side is a fairly new conference dedicated to running Swift applications on the server. In practice, many people from the Swift server-side ecosystem attend this conference. I attended the second edition of this conference, held from Oct 30 to Nov 1, 2019 in Copenhagen.
I had missed the first edition last year in Berlin, but this second edition was a nice opportunity to meet with the community. Some people are still a bit reluctant to bet on Swift on Linux due to the fear of Apple being too prominent in the development of the server ecosystem.
However, this is not a worry, if I should judge from the mindset of the community. The crowd was extremely involved in the Swift server-side environment, coming from various companies. People came here not to listen to Apple directions. They got there because they are passionate about Swift and feel it is a very good fit on the server, a good middle ground between Rust and Go.
The developers there are well aware of the current weakness of Swift on the server, and are not waiting for a large company to solve them. The community created the Swift Server Work Group (SSWG), is working on sharing common pieces of code between frameworks to avoid redundant work. The SSWG has a plan and the community is building piece by piece the missing parts in the ecosystem, from Open Foundation improvements (the standard library) to various types of drivers and libraries.
What I have seen at work is a vibrant, highly knowledgeable community that has a plan to get to the point where Swift on the server is a solid choice for developers.
Day one was dedicated to workshops. I attended two of them and enjoyed working directly with the main developers of each project.
Contributing to SwiftNIO and SSWG
I enjoyed being guided by Johannes Weiss & Cory Benfield on how to contribute to the Swift Server Work Group and on SwiftNIO. They have been happy with the result of their workshop, with 30 pull requests for SwiftNIO to process during the following days.
Build a cloud-native app with Kitura
This workshop was an introduction to Kitura, guided by its lead developer Ian Partridge. It was a nice way to get into Kitura, and see the benefit of using Swift on three projects developed in parallel: A Swift service running on Linux, a MacOS admin dashboard and an iOS client.
You can follow the material of the workshop on your own, using this repository: Kitura SOS Workshop
Conference Day 1
Swift Server Work Group Update (Logan Wright)
It was a nice summary of the progress of the Swift Server Work Group and showing the road ahead for framework and library developers. The bottom line is that the number of committers on all Swift server and library project is growing. By coordinating the effort and by sharing code, the community is hoping to reach the point where developers have access to all the library they need to build their applications. Beside a common network framework (SwiftNIO), we now have Metrics and Logging initiative, as well as several database drivers, part of the SSWG effort.
My personal point of view is that the ecosystem development will accelerate. As Apple has now added support for Swift Package in Xcode, it is possible to write libraries that will work both on iOS, MacOS and Linux. This is going to grow the package set even faster.
You can learn more about the progress here: SSWG Annual Update
Resilient Micro-Services with Vapor (Caleb Kleveter)
Caleb Kleveter did a good job at explaining the best practices to build Micro-Services in Swift, inspired notably by his work on SwiftCommerce.
Some advice applies to micro-services in general, not only Swift ones, especially regarding “external” resilience:
General abstraction rules are more specific to Vapor:
Static site generation in Swift (John Sundell)
He announced that his static site generation tools — Ink, Plot and Publish — will be open sourced by the end of the year. You can follow him on Github to check when the code will be released: github.com/JohnSundell
API Performance: A macro talk about micro decisions (Joannis Orlandos)
Joannis Orlandos gave us some food for thoughts about API performance, from the different point of view:
– For users: performance is often response time
– For developers: it is more often requests per second
– For sysadmin: it is CPU and memory footprint
– For management: it is development time and hosting cost
SwiftNIO solves most aspects of the server-side performance, with development time being often addressed by frameworks on top of SwiftNIO.
He also shared practical tips, like for example to avoid auto-incremental ID in database, in favor of UUID, to limit locks on the increment code.
Cloud-native Swift micro-services (Ian Partridge)
Ian Partridge did a very good job at presenting the progress of Kitura itself and the set of tools around the Kitura framework. Most notably he mentioned:
– The release of Kitura 2.9
– The SwiftKafka library (a wrapper around …)
– The Hystrix library (not a Swift project directly, but useful to use in micro-service architecture)
– Circuit breaker
Breaking into tech (Heidi Hermann)
Heidi shared her experience and her view on the tech community and gave advice on how we can improve it to be more welcoming. It was a really great talk and she properly demonstrated that, as a whole, we are failing at training and helping people make progress, and bring other views, opinions and backgrounds into our companies.
As she said, most of the tech companies these days are only hiring senior developers. They consider the pressure to deliver is higher than the need to prepare the future. However, when stated this way, it is clear it is not sustainable, especially, as there is a shortage of experienced developers. We all need to work to build the tech community of tomorrow.
Building State Machines in Swift (Cory Benfield)
It was another fantastic talk. Coming from an Erlang background, where state machines are a first-class process type (see
gen_fsm and now
gen_statem), I really enjoyed Cory’s take on the Swift-friendly approach. Thanks to enum and type checking, Swift help you write robust and safe state machines.
He also shared a lot of nice design tips, showing how to properly encapsulate the states as enums to prevent users of your State machine to mess with it.
Swift Development on Linux (Jonas Schwartz)
Finally, Jonas Schwartz shared his setup and tips to develop in Swift on Linux. While it is clearly a bit rougher than using a Mac to develop in Swift, he showed that it is definitely possible. Once you are set, it can be even be an enjoyable experience.
Server-side Swift Panel
The panel concluded the day with a lucid overview on what is currently working well with Swift Server-Side, like the fact it is already production ready, or the coordination effort of the community being very good, but also covered the missing pieces, like missing integration of async/await in Swift language at the moment and needed improvement on Foundation on Linux.
and Day 2 …
In a next blog post, I will cover day 2 of the Server-Side Swift conference and share my conclusions.
In the meantime, do not hesitate to share your questions, concerns or feedback about Server-Side Swift.