HACKER Q&A
📣 _448

What is the future of Swift on the server-side?


I am in a dilemma on which language to choose on the backend for my project. I am looking for a performant, statically-typed, systems programming language. I know C++. But C++ has become somewhat an over-engineered language that is mostly in a to-be-not-to-be state of feature development. So I looked at Rust and it already seems going in the direction of C++. So I looked at Swift, and I like what I see, but I am not sure if the language has any serious users on the server-side. IBM was one who was part of the group working on server-side features of Swift, but left the group sometime back.

So I was wondering if anyone here is using Swift and or Vapor for backend development?

What are the other alternatives, Nim?


  👤 gargs Accepted Answer ✓
I have a production app live using Swift/Vapor. I created this app solely for the purpose of learning full-stack development using Swift, and so far it has been an amazing ride. The best thing about using Swift on the server if you're already an iOS developer is that a ton of models and DTOs are simply shared across your backend and your app(s).

I have deployed my backend on a tiny DO droplet using Docker, and it just works. There was a slight bit of learning curve for deploying it, but I can now create images locally on my Mac and pull them remotely for a fresh deployment/migration in less than a minute. Being able to build locally using Docker for Mac also means that the speed is great.

Before that, I had the app live on a Heroku setup but it cost quite a bit.

My app is at https://apps.apple.com/nl/app/instint/id1454800508


👤 cy_hauser
Google's Go language is well suited for back-end code. However, it's a very opinionated and quirky language. If its style suits you it's a great choice. If, after looking at it for a bit, it doesn't sit well then nope.

👤 nicoburns
Non-existent unfortunately. Swift hasn't taken off outside of the Apple ecosystem, which is of course heavily client focussed. If you like the look of Swift, but you're writing backend code then I would definitely recommend Rust. It's actually super nice to work with. Not at all like C++.

Other alternatives would be Kotlin, C#, Go, or even Java.


👤 jdmcd
(Disclaimer: I am a member of Apple's Server Side Work Group (SSWG) and these opinions are mine and mine alone)

We (Transeo [1]) use Swift and Vapor to power our application which serves millions of users and regularly hits 20k requests per second. We're running on substantially less hardware than we budgeted for, which is great, and the performance is also notable - our p99 response time at peak rps is ~250ms.

That being said, performance isn't the only thing that you should look for when choosing your backend language/framework, as you've noted. We've been using Swift/Vapor for more than 5 years now so we've seen the community grow alongside it, and I am really excited about where it's going. While the ecosystem at one time was a bit of challenge (in terms of finding a package to do something, etc), over the last ~2 years we have rarely run into problems finding code snippets or packages to accomplish our tasks. We do a lot of bulk CSV processing (hundreds of gb's at a time), SFTP transfers, PDF generation/merging, calculated database locking, all of which has been relatively seamless ecosystem-wise. Check out the SSWG projects [2] for some more cool stuff happening in the ecosystem.

Hiring has been fine as well - we have a number of developers on the team that did not have Swift or Vapor experience coming in and were able to map other frameworks on top of it and pick it up quickly.

All of that being said, I will admit that I am biased on this topic :) Frameworks and programming languages are merely tools in your tool-belt, and different tools are right for different workloads.

[1]: https://gotranseo.com [2]: https://www.swift.org/sswg/


👤 rockyj
Given your criteria, Go might be a good choice maybe. It has a bigger or shall we say a more "successful" backend story.

Regarding Swift I am not sure how popular it is for the backend, you might not have a lot of libs for example for doing common things. Also no idea well a Swift backend performs under load. Swift is a nice language for sure, maybe if you can risk it, go for it but keep also this in mind - https://boringtechnology.club/


👤 pornel
Swift's performance is a mixed bag, and can be closer to JavaScript than C++. It heavily depends on how you manage your objects and how many memory allocations and copies that causes. Swift prioritizes nice syntax over implicit overheads, so it's something to look out for.

If you really really need something high-performance, then Rust is the main contender. Don't be fooled by superficially similar angle brackets syntax. It's not similar to C++, it's is not even a C-family language (closer to ML). Things like having multiple string types may seem like the same mess, but it's not a legacy baggage like in C++, but an explicit meaningful choice exposing ownership and encoding semantics.

If you merely need pretty good performance, go for golang. It's very successful for services.

I don't see room for Swift in server-side languages. It won't be able to shake being Apple's technology first, and having Linux support as a second class. It's not low-level enough to beat Rust on performance. It can't compete with popularity and ease of use of JS/TS and golang.


👤 alfonsog2
Amazon Prime, Mercedes and allegro have been using it. There is a conference happening soon, so you can get more inform https://www.serversideswift.info/

👤 netshade
Currently using Swift for a side project. It's "server side" in that I have a server implementation that runs on an iOS device and in Linux on a server. Using SwiftNIO for the server pieces, as it's from the Netty folks, and I really like their design.

I've been happy with it thus far, even though I should note that my usage is pretty low stakes / trivial. It has just enough of what I want of modern language conveniences that I'm not sad about using it. I certainly derive some happiness from having a zero impedance inclusion on the iOS and server side; conversely, were I to use Rust, my early reading seemed to indicate I' have to navigate a bit of FFI and library inclusion on the iOS side that I'd much prefer not to.

So, at hobbyist level, it's been fine. If I were to go purely on technical merits and language niceties I would have chosen Rust, as the depth of language features and standard library features is really really nice for me, but the fact that I can just have something that works in either of my desired platforms has made it okay to deal with a slightly less mature (IMO) ecosystem.

Also, as a note, I've done just a tiny bit of SwiftWASM with this same toolset, and it's not bad either. Pretty far behind Rust's WASM capabilities in my experience, but accomplishes what I need and is generally nice. Tokamak ( a WASM-friendly UI framework like SwiftUI ) has been nice in my initial usage as well. I'm definitely at a firm hobbyist level of using this stuff tho, no production anecdotes to give you unfortunately.


👤 FlyingSnake
> backend for my project

> a performant, statically-typed, systems programming language.

What is your project about? What are the latency requirements? How many concurrent users you expect to have? If these numbers are not high, why are you not using a general purpose language like go or Kotlin?

I used vapor for a evaluation project a while ago and abandoned it quickly. While Swift is a nice language, it is still a 2nd class citizen on non-Mac systems.

You can do a small PoC project and see if you like it.


👤 frou_dh
Its future is the same as its present: niche server-side choice only used by Apple-adjacent developers.

Such a squandered opportunity on Apple's part. In the early years, the Swift team talked a big game about wide industry adoption goals, but multiplatform seems to just be a defeated box-ticking exercise now.

People say Apple are an unstoppable marketing machine, but they did an absolutely horrific job of engaging the wider software development community with Swift.


👤 bsaul
As a fullstack dev, focused on ios dev for the past 10 years, i'd say swift for anything other than ios/macos dev is pretty much experimental.

The community tries to expand swift's horizon with all its heart, but as long as apple is the main force behind the language there's going to be no real incentive for it to become a serious contender on other platforms.

I'd recommend go, if it's a serious project you plan to maintain for years.


👤 hedgehog
I've used Swift for iOS development and generally like it. There's no technical reason why it couldn't be great for server-side development but there are two major reasons I wouldn't expect it. First, there's no painful gap to drive adoption. Go and bit by bit Rust are both reasonable statically typed, compiled languages with good ergonomics and performance. Second, there isn't a strong community of corporate and individual developers supporting use outside of iOS. That means few people, but also little tooling. I was excited by the extensibility and some of the stuff the TensorFlow team was doing but there just doesn't seem to be enough reason to pick Swift over one of the more mature alternatives. Even on Apple's own platforms there's only full support for the latest macOS release. I'm guessing the calculation is that iOS is a big enough carrot to keep a community of Swift developers around and Apple doesn't see growing beyond that as a priority. Fair enough.

👤 malermeister
> What are the other alternatives, Nim?

You should check out Kotlin. Design-wise, it's very similar to Swift, but it has a bigger userbase on the backend and an (imo) more promising future.


👤 andsoitis
What is the nature of your project that you need a “systems programming language” server-side?

Asked differently, why are Java (or a mature JVM language) or C# not a good fit?


👤 metaltyphoon
IMO the better alternatives would be Go, Kotlin or C#. Much better ecosystems where you won't have to keep reinventing wheels.

👤 ChrisMarshallNY
I'm pretty sure that the objc.io[0] people are using it for their site. Much of their SwiftTalk series[1] covers work on their backend. They are fairly serious players.

For myself, I won't use it on the server, but that's because I write servers for relatively low-cost, limited-skill, demographics. I use PHP.

[0] https://www.objc.io

[1] https://talk.objc.io


👤 nwsm
I was also interested in server sided Swift for a bit but didn't go very far with it.

Java is the "obvious" choice for statically typed web backends. Personally I'll recommend Go and C#. Both have a low learning barrier to entry, check your boxes for backend languages, and have ample resources online. I would choose C# (on ASP.NET Core) if you want flexible typing and inheritance, and Go if you want "simple" imperative code. Rust is also popular but I don't know enough to comment on it.


👤 rubyfan
Seems like you know the answer. It probably depends on what your goals are…

If you intend to make money and or invite a team into the project over time then maybe look for something lots of people use (.Net Core, C++, TypeScript, Java, etc.)

If you want this project to be a labor of love that is mostly powered by you then pick whatever esoteric thing you want that fits the bill (again sounds like you know the options, Rust, Crystal, Nim, Server Side Swift, etc.)


👤 adenozine
I have also been keeping an eye on it for the past couple of years, but without significant outside commitment, I'm hesitant to do anything serious with it.

Swift is a really nice language, much easier to skill up than Rust and MUCH better ergonomics, but again, IBM pulled out and the working group moves at a glacial pace...

I'd be curious to hear as well if there are any corps quietly relying on it.


👤 bytehowl
I have a couple which others haven't mentioned yet. I have very little/no experience with them, but what I have read about them matches your criteria, so they might be worth a look.

Crystal (like Ruby but fast and statically typed)

D (a "better" C/C++ with GC)

Pascal (a C/C++ competitor which has fallen out of favor, but is still being developed as FreePascal)


👤 eob
We (steamship.com) use Swift on the server to power our Heroku-style AI apps platform.

It’s been mostly great. Only downside is the server-side swift community is smaller than others, so you don’t get the deep software library selection something like Python would have.


👤 chunkyguy
> But C++ has become somewhat an over-engineered language that is mostly in a to-be-not-to-be state of feature development.

You can say the same for Swift. But just like with C++, you can always stick to simpler and smaller subset and make great things with it.


👤 fredgrott
Dart has some backend projects and support and is statically typed.

See Very Good Ventures own Dart Frog:

https://github.com/VeryGoodOpenSource/dart_frog


👤 ergonaught
Not really a fan of the language, nor necessarily a fan of the decision, but “rust in the Linux kernel” should probably tell you the future of systems languages and suggest a re-evaluation of the language.

👤 bryanlarsen
I think you're misinterpreting the direction of Rust.

Rust 1.65 didn't add a new feature, it removed a limitation on an existing feature.

That's the direction I want my languages to be going in.


👤 codenesium
The list is long. If you're familiar with c++ take a look at C#. Go and Java are safe bets as well. Beyond that there are a million backend languages out there.

👤 ribmint
Swift on Server has become quite mature over the past years. The ecosystem features a libraries for a lot of tools you want to integrate. Furthermore, it is being used in production by some major companies besides Apple, e.g. Amazon has a bunch of production services running on it. One of the greatest things about Swift on Server is not only the language but also the community. They are very open to new joiners and try to help whenever possible. Furthermore, with the latest Swift features such as Swift Concurrency it looks even more promising.


👤 auggierose
Use TypeScript/Node. It might be system enough for your purposes, and typed enough also.

👤 neoneye2
For backend I switched

from Swift using https://www.perfect.org/

to Rust using https://github.com/http-rs/tide


👤 antifa
Crystal is pretty hot for server side applications.