Hacker News new | ask | show | jobs
by jshier 891 days ago
They're literally rewriting in Swift right now. Foundation is being rewritten entirely in Swift. All new code is in Swift. All new frameworks are Swift-only. They're using Swift from low level firmware on the Secure Enclave to apps. This is already real.
4 comments

> Foundation is being rewritten entirely in Swift.

That's a mult-year project in its very early stages, yet we're already almost 10 years into Swift (more than 10 years of Swift internally to Apple).

> All new code is in Swift.

False.

> All new frameworks are Swift-only.

False.

> That's a mult-year project in its very early stages, yet we're already almost 10 years into Swift (more than 10 years of Swift internally to Apple).

It has already shipped, replacing parts of Foundation in the 2023 OS versions. It continues to grow, and it's a rewrite, so it certainly proves your assertion wrong.

My other points were a bit hyperbolic. Feel free the replace "all" with "the vast majority of". Apple obviously still writes Obj-C in their existing Obj-C frameworks, and doesn't arbitrarily rewrite into Swift, but their internal barriers to use Swift are now almost entirely gone. And I can't think of an entirely new framework that wasn't Swift-only recently.

> It continues to grow, and it's a rewrite, so it certainly proves your assertion wrong.

Which assertion was wrong? I was paraphrasing from the project page itself:

"It is in its early stages with many features still to be implemented." https://github.com/apple/swift-foundation

> Which assertion was wrong?

Your original assertion that Apple wasn't rewriting anything.

> Your original assertion that Apple wasn't rewriting anything.

I have no idea what you're talking about. I made no such assertion.

Perhaps you're confusing me and "toyg"?

Ah true. Not sure why you replied then. Your point about Foundation was meaningless and the others just nits. Do you have an actual point to make?
This is turning into a silly argument… but anyway there's a blogger who has been tracking the number of binaries written in the various languages (and appkit vs catalyst vs swiftui etc.) for years.

Sonoma is 13% Swift (up from 11% in Ventura), 53% Obj-C (down from 55% in Ventura). The priority actually appears to be eating away from the C/C++ parts of the codebase (currently 33%, down from 42% just two releases ago).

https://blog.timac.org/2023/1128-state-of-appkit-catalyst-sw...

At this point you can't separate Swift from the rest of the system so cleanly. Since it's now included with the OS directly and linked to from many system libraries, including parts of Foundation which have been directly rewritten in Swift while maintaining ABI compatibility with Obj-C callers, virtually everything on the system that uses Apple's frameworks uses Swift to some degree.
Yup, exactly. Swift was specifically designed to replace Objective-C and C++ throughout Apple codebases (see https://www.youtube.com/watch?v=ZQc9-seU-5k).

C# is a totally different story.

> C# is a totally different story.

Interesting. Can you share more details?

Disclaimer: I work for Microsoft, though I wasn't there during the early days of .NET or Windows Longhorn.

C# was created as a Java competitor. Although it had great C interoperability, the underlying .NET Framework was still a VM-based runtime with a garbage collector and all the disadvantages that brings. You can probably find various articles (https://longhorn.ms/the-reset/ is one) discussing attempts to adopt C#/.NET code for Windows Longhorn, which ultimately had to be walked back completely. .NET wasn't purpose-built for writing OS components or working deep inside existing Windows code.

Apple learned from this and other examples. The Swift team actively works with teams at Apple deep in native code to make sure they can handle their use cases without performance penalties, and with minimal ergonomic issues.

The difference is really about what the stated goals of the language were/are.

Thank you to share. My guess: In the year 2000, it was impossible with current desktop computing power to use C# for OS internals. In 2024, it is a different story.
That's what MS said as well, when they were pushing C#. All Windows will be using safe code! Still waiting... Another example is Mozilla and Rust - hell, I wouldn't be surprised if there was still Netscape code somewhere in the bowels of FF/TB!

Sure, Apple cares less about backward compatibility, but still, it's unlikely Objective-C is going anywhere, under the hood.