Hacker News new | ask | show | jobs
by vtail 224 days ago
Do people use Swift outside of Apple iOS/macOS development in real life? Especially on platforms like Windows/Linux/*BSD?
11 comments

I’m using it on Linux for an embedded product. No reason other than it’s a nice language that I am familiar with and productive in. The async/await features are quite nice too when you need to implement a lot of protocols / state machines.
Personally I stay away from Corp owned languages. Even cross platform ones like .net, Java and also swift. With the single commercial party owning it you never know if theyll close it, change things for the worse or get acquired by a hostile party which obviously happened to java :(
Which language would you classify as not corp owned?

It’s also weird to include Java and Swift in that list considering both afaik are maintained by a separate foundation. Java from Sun is even predominantly basically OpenJDK with some remaining proprietary Sun / Oracle bits but it’s the reference open source implementation used by most everyone.

> Java from Sun is even predominantly basically OpenJDK with some remaining proprietary Sun / Oracle bits but it’s the reference open source implementation used by most everyone.

Note that Oracle contributes around 90% of the work to OpenJDK. If they decided to stop working on it, there would be a big gap to fill.

That’s generally true of most languages. Rust is struggling with this right now.

I’d say though that Oracle is highly unlikely to stop working on Java and Google is still invested in the JDK even though they’re trying to shift new code in this space towards Kotlin (another “corp owned” language)

Python, Zig, Elixir, JS, C to name a few?
Also rust, c++
> Python, Zig, Elixir, JS, C to name a few?

For a significant portion of time Python was funded by Google, Meta and Facebook and maybe some other corps.

Zig doesn’t have any serious adoption in the industry yet but if/when it does I’d expect corps to be hiring the language devs.

JS is a consortium but it’s filled primarily with Google and Apple engineers.

Same goes for C/C++ lot of Apple, MS and Google engineers.

Elixir I’m not sure about. Rust was largely turns out employed by Amazon until the most recent culling.

It’s not surprising. This is technically difficult work and if the language is important to a corp they’ll hire the maintainers. There needs to be a funding source and in the industry that typically means a for profit company paying the salary of the people moving things forward. Indeed - it’s one of the things Rust is struggling with for now.

They fund it cos they want to use it for their thing. Does not mean they own them. They are all community governed projects.

Rust, Julia, Typescript on the other hand are governed by Corps. They are not community projects.

Elixir is BDFL (good one) last I checked. Dont know if they became a company or foundation.

Zig is for all purposes a good example of community governed project. Itcs in production at Bun and TigerBeetle. But also, its not yet production ready (v1.0). So their current trend make sense.

But I could've been wrong with JS and C. Not sure about their governance now that I think about it.

I may be wrong, but I think what they meant was rather "funded mostly by a single corp". Bus factor.
Nope. Rust is governed by corps. Its not a community project.
Sure, but slightly better than one corp.

One can argue about that - but probably not in context of the sub-thread:

> With the single commercial party owning it ...

Which corps govern rust? I’m not aware.
Apple’s the exception that proves the rule, they do a fantastic job supporting legacy APIs, frameworks, and devices
I’ve been in the Apple ecosystem in one form or the other 40 years and that’s definitely not true compared to Microsoft.

Most recently they dropped support for 32 bit Mac and iOS apps. But before that it was dropping support for PPC apps and 68K apps.

On the hardware side, the funniest was they dropped support for my Core 2 Duo Mac Mini and I could still install a supported version of Windows 7 on it.

> they do a fantastic job supporting legacy APIs, frameworks, and devices

They do not.

They talk a good game, but the development tools, bright and shiny, but mostly work.

Mostly, is not good enough.

While they have so much mind share in the USA they are unavoidable. But from a developer perspective they are dire

As of two years ago. I find it hard to believe they have changed

There are 10 different answers for how to take a substring by index+len, depending on which version of Swift. They even changed how arrays as function parameters work between versions.
So then just use one version of Swift
Not viable to stay on an old version, especially doing iPhone dev. The real answer back in the Swift 1-4 times was to just use ObjC instead, it still had full support.
Arc browser famously had native parts of the UI done in Swift, which admittedly is not a lot: browser tabs, some popups and buttons here and there, a lot of their settings UI is rendered in HTML and is stock Chromium. Which is probably why they actually made a port of it to run on Windows rather than rewriting it into something like Qt or WPF or whatever.

Ladybird browser team planned to start using Swift in their codebase, but it hasn't happen yet.

  > Ladybird browser team planned to start using Swift in their codebase, but it hasn't happen yet.
whats the holdup?
Chicken/egg, I think. There was a burst of activity of Swift on the server a few years ago and frameworks like Vapor seem like they’re still pretty active:

https://vapor.codes/

But I think “why” remains a valid question when you could make a safe pick like Node, Python etc. I really like Swift as a language but I’d still struggle to justify using it outside of iOS.

There were three major server side Swift projects, and Vapor is the surviving one from that era

Dead projects are

- Kitura https://github.com/Kitura/Kitura

- Perfect https://github.com/PerfectlySoft/Perfect

Don't know of large organizations using it in production, the vibe I get is that it's useful for an iOS developer who wants to deploy a small server for their product without learning Python or Javascript.

You could certainly use it at larger scale, but you have to justify giving up the big ecosystems of its competitors.

Sadly this project is getting steadily slower. Adopting async made it slower than Django. But this is due to Swift limitations. Hopefully Swift replaces Codable and improves async performance.
Swift is a peer to Rust, not Node / Python. It has some nice affordances that Rust doesn't, while still being a native-compiled language.
It's more of a peer to Go
In the case of Vapors (building "HTTP servers, backends and APIs") I'd say Node and Python are absolutely alternatives.
So is https://gotham.rs/!

I think they were just talking about the language features, not building web services generally

Swift is absolutely not a peer to Rust. Even without GC, Swift comes with a substantial runtime to enable a lot of features that precludes such a comparison like everything to do with messages and actors. With regards to safety, Swift's data isolation system is cute, but isn't comparable to a substructural type system at all, and it's useless if you're not writing code that uses actors.

Most of what makes Rust's safety powerful is that lifetime analysis is universal and highly granular. Things like no dangling references to local variables, no 'collection cycles', handling parametric code, etc. are basic features that Swift can't provide. On top of it all, the whole system is ruinously complicated compared to Rust's type system. That's the sad reality of what happens when you try to implement something so fundamental as an extra bolt-on to a language that can't properly accomidate it.

On the other hand, Swift has a more gentle learning curve with plenty of progressive disclosure (many features aren't strictly required to build something useful) and generally more approachable syntax.

Swift is also more conducive to "old style" retain mode imperative UI frameworks like AppKit (sometimes declarative and/or immediate mode doesn't fit the bill), which has to date been a major weak point for Rust.

For what it's worth, I'm not an active user (or fan) of Rust. I've just used a lot of languages, it's a hobby of mine to learn new tools.

> a more gentle learning curve ... and generally more approachable syntax.

This is all the more reason it's not a peer. The heavyweight class Rust belongs to (which includes things like Sepples, ATS, Ada/SPARK, D) are as a rule not approachable things. All of them are serious industrial tools whose target audience are experienced professionals that prioritize extremely broad functionality and flexibility in output. What the input looks like, or the cost of learning to operate these tools is not even a consideration for this audience. Swift doesn't fit this bill. It simply compromises too much for things that this class of language isn't concerned with. People reaching for a new language in this class aren't thinking about how easy it is to learn, or even how nice it is to use. Rust abandoned ML-family syntax to babyduck C++ at massive cost to its "niceness".

On syntax, do you mean semantics? Syntactically they're both generic curly-brace algol stuff with minor differences at best. Semantically Rust is certainly more complicated.

> which has to date been a major weak point for Rust.

It's very ironic, given Rust's original purpose was to replace C++ as the implementation language for Firefox. Retained mode GUIs have unfortunately fallen by the wayside due to a number of factors, it's not just unique to Rust. If a language hasn't inherited a legacy retained mode lib, it's not likely it'll get a decent one unless it's really lucky. Unfortunate, because you're right, retained mode GUIs absolutely have their upsides and web browsers aren't a solid replacement. They're just complicated to implement, and computers are fast enough now that the much simpler immediate mode paradigm is the choice for every new framework being written. It is what it is.

Does not support Windows.
Like Rust, Swift is a compiled language that offers memory safety and data race safety by default.
Data race safety is not offered by default. In Swift 6.2 you can enable strict mode and it will cover majority of data race problem, but not all.
> by default

As far as I know there is no clear boundary between safe and unsafe.

Not really that much

It's been two years since I was an iOSSwift programmer, but the concurrent/parallel facilities were quite woeful. Memory protection no nonexsistant

I do not miss it. This might be useful for porting Apple software, but do not start new projects with it.

Swift concurrency used to be a bit rough around the edges, but since Swift 5.5 it uses async/await and structured concurrency, which has been a massive improvement. We also have built in ways to handle data races around mutable state with actors and the main thread with @MainActor.

Rust has a more explicit and strict approach to ownership/borrowing for sure, but I’d argue Swift has worked to be memory safe be default since the start, with ARC, no unchecked pointer arithmetic in normal code, etc. it’s still tightly coupled to Apple platforms, but the swiftlang teams has been hard at work changing that and I think it’s a fine language to start new projects with in 2025.

async/await is useful

But what Swift lacked (in my day) was any support for parallelism.

They wrapped `fork` in a lot of mumbo jumbo, but it was just `fork`

May as well use C

> Memory protection no nonexsistant

Exclusivity is guaranteed by the compiler, and Apple has integrated tagged pointers on arm while Linux/x86 is still thinking about it.

Righto. "Non-existent" is going too far.

I played around with their threads and found it was trivial to corrupt memory and crash.

I guess so. In a way it makes sense if you can share your code base between the iOS/MacOS app and your backend. It makes development easier. But I guess that the majority of apps is not running MacOS servers for the backend. So far it's probably some node backends and all going JSON inbetween. But for some dedicated apps without a web portal inbetween it might be easier if app and backend are both in Swift.
It’s not super popular, but support is necessary to make it so. There are some well-regarded frameworks, like Vapor, that are written in Swift.
It'd be nice to use it for server side too, but the ecosystem is really not mature and the build system is not on the same level of Gradle or similar.

Plus, most of the open source libs are one person's weekend projects, from 3 years ago...

It's a great language, but nowadays tooling/ecosystem and build systems are key to success.

> …and the build system is not on the same level of Gradle or similar.

Worth noting that Gradle's long list of capabilities can sometimes be as much of a liability (or at least a frustration) as it is a boon. A great many projects don't need even a fifth of its complexity.

Examples?

I think I have always seen it used in a relatively "simple" way. But that might be... "relative". :)

My encounters with Gradle have mainly been through Android development, so the example that springs to mind is how much of a pain in can be to get a project that's been sitting for a while patched up.

Basically, as a result of dependencies working only with certain versions of Gradle, it's very easy for an project with moderate to high complexity to wind up in a huge tangled mess when updating anything — updating Gradle might require you to update your dependencies, but all your dependencies might not support the version of Gradle you updated to, and the errors that get thrown as a result will be generic and won't tell you as much, sending you on a goose chase. This chain of events can also be set off by upgrading a single library for some feature you need.

It also makes it a pain to read others' Gradle files since there's no agreed upon standard, with everybody doing it a little bit differently.

In contrast, in the several years after switching my Apple platform projects to Swift Package Manager and away from CocoaPods, it's been rare for either toolchain or library upgrades to cause any sort of problem, and broadly speaking there's only a single correct way to write Swift package files, which makes them easier to read and work on.

Yes, because Apple gave up on the server market, so that demography usually uses Linux based servers and does code sharing between backend and their iDevices apps.
Only for iOS apps. Apple does not offer a backend.
Not true at all. Swift is a very capable backend language, Apple has open sourced a lot of great libraries to power server software development, and there are projects like Vapor [0] that are used in production.

[0]: https://vapor.codes

Ah. You're right, I phrased that ambiguously, sorry.

I meant to point out that there is no apple native cloud solution where you can run swift on apple hardware.

So if your iOS app needs to talk to a backend that you want to develop and host, you need to run that backend on an OS with cloud support, like Linux, some other Unix or windows. But not macOS or some other "Apple cloud" hosting.

For reasons stated above, you might in that case choose Swift.

Ah, gotcha—yes, that is actually a pain point and a strange omission. If you need to run backend code for any reason to support your app, Apple literally offers nothing.

IBM at one point offered Swift "serverless" lambdas/cloud functions, which made me briefly hopeful that Apple could do the same, but that service was deprecated years ago, and Apple has shown no motion there.

Also announced today… AWS official support for Swift lambdas: https://aws.amazon.com/blogs/opensource/the-swift-aws-lambda...
Could SwiftUI ever be used outside of Apple?
SwiftUI is build upon Apple's frameworks like Metal, CoreGraphics, CoreAnimation, and UIKit / AppKit. If someone want's to make a version for another platform, they will have a whole lot of work to do. That is the real show stopper, and not the core SwiftUI features like many were led to believe
Probably not, Apple would have to opensource it and that’s unlikely
No