by danpalmer · 3y ago · 0 comments
I have recently been developing a server-side Swift application, a few months of sporadic evenings and weekends. My starting point was having a year or so of professional iOS experience and a ton of web/server/infra experience.
My experience with it has certainly been mixed, but in many ways a breath of fresh air compared to some web development ecosystems. At work I'm mostly using Java on the backend and I think Swift could be a really nice replacement for that for larger systems – the type system is better, the ergonomics are better, the developer tooling is much better at the lower end (although there's plenty of specialist JVM tooling that is better).
Ecosystem-wise, Swift has few but high quality libraries available in general. Apple's first party libraries are exceptional. Vapor is in a weird place though. Some parts are really mature and well considered for their relatively young age (e.g. parts of the ORM, async stack), others feel very early days for things that have been around for a number of years now (e.g. queues). Others feel like an impedance mismatch in the framework design – I find the Content system both too limiting and not providing enough.
Overall, I'm loving it for a personal project. Would I use it as the foundation of a new startup? Probably not. Would I use it in a iOS heavy company? Yeah probably. I think you can do productive, high-quality backend engineering in Swift, today.
I think a lot of the author’s problems started when he bailed on Vapor and went down into the depths of SwiftNIO. I’m not really sure this was necessary. I could be wrong, but it feels to me like Vapor should let you do pretty much everything that you would need for an ActivityPub server.
Writing request handlers in Vapor with async/await is delightful - it’s really not any harder than writing Flask code. But going down below that level is pain. Lots and lots of pain.
You're right about the NIO part. I've had to dig into it a few times, but rarely found it productive in solving problems. Vapor is pretty flexible if you drop past it's first layer of abstractions, and as long as you pick one of futures/async and stick to it, it's fairly straightforward.
The best side benefit for our Java heavy org was that the migration risk is very low due to excellent JVM/Java integration.
As the project progressed we started adding more in Kotlin and it massively improved developer experience.
Most Java tooling works with Scala out of the box or at most needs a plugin added, and interop when calling Java from Scala is very smooth. Even if it wouldn't be acceptable for production code you might consider trying it for migration scripts, admin tools, testing etc. (though personally I'd stay away from ScalaTest et al) - that's how I got my start with Scala many years ago.
The community is a bit worried over these developments, and there has been some sniping over the disruption caused by Scala 3 (mainly to projects that relied on macros, even though macros were marked as an experimental feature).
IMO Scala is still the best language on the JVM, and last I checked there were plenty of jobs for experienced Scala devs. The foot guns weren't that severe, or at least I am used to them (in my opinion, Java coding has more foot guns due to nulls and mutable state everywhere, YMMV).
Scala 3 was more incremental, than radical, and was massively less disruptive than you see with other attempts to clean up a language (Python 3, Perl 6, anything involving PHP) due to good design, careful planning and backwards compatibility options.
Erm, including the apparent signal race and the illegal instruction?
Yes. They're probably both caused by this person setting their CPU microarchitecture wrong.
Haha, what?
Linux/Windows tooling is lacking, I'll give you that, but given where Swift started from I feel like they're already outside the norm for Swift development and debatably "low end" on complexity (although not deployment, I haven't had a problem with Linux deployment).
By "high end" I mean anything that is trying to do complex runtime analysis, and the sort of tuning that you can do on the JVM that is way outside my comfort zone.
"Install Xcode, click New Project" is a much lower barrier to entry than setting up the toolchain in other ways.
I know of a medium-size startup that is (attempting) building an industrial/IoT software stack on just Swift. Last I heard things weren't going great...
They have a lot of shared ideas and even shared developers.
Swift is effectively ref counted rust imho