Remix.run Logo
gjajric 2 hours ago

Swift does not seem suitable for OS development, at least not as much as C or C++.[0] Swift handles by default a lot of memory by using reference counting, as I understand it, which is not always suitable for OS development.

[0]: Rust, while no longer officially experimental in the Linux kernel, does not yet have major OSs written purely in it.

astrange an hour ago | parent | next [-]

There's an allocation-free subset.

https://www.swift.org/get-started/embedded/

Rust's approach is overkill, I think. A lot of reference counting and stuff is just fine in a kernel.

gjajric2 29 minutes ago | parent [-]

But at least a lot of tasks in a kernel would require something else than reference counting, unless it can be guaranteed that the reference counting is optimized away or something, right?

pornel 26 minutes ago | parent | prev | next [-]

Apple is extending Swift specifically for kernel development.

pjmlp 2 hours ago | parent | prev | next [-]

What matters is what Apple thinks, and officially it is, to the point it is explicitly written on the documentation.

gjajric2 32 minutes ago | parent [-]

The practical reality is arguably more important than beliefs. Apple has, as it turns out, invested in trying to make Swift more suitable for kernel and similar development, like trying to automate away reference counting when possible, and also offering Embedded Swift[0], an experimental subset of Swift with significant restrictions on what is allowed in the language. Maybe Embedded Swift will be great in the future, and it is true that Apple investing into that is significant, but it doesn't seem like it's there.

> Embedded Swift support is available in the Swift development snapshots.

And considering Apple made Embedded Swift, even Apple does not believe that regular Swift is suitable. Meaning that you're undeniably completely wrong.

[0]:

https://github.com/swiftlang/swift-evolution/blob/main/visio...

pjmlp 15 minutes ago | parent [-]

You show a lack of awareness that ISO C and C++ are also not applicable, because on those domains the full ISO language standard isn't available, which is why freestanding is a thing.

saagarjha an hour ago | parent | prev [-]

Nothing wrong with using reference counting for OS development.

gjajric2 30 minutes ago | parent [-]

Even kernel development? Do you know of kernels where reference counting is the norm? Please do mention examples.