Live data from Hacker News

Apple announces full Swift rewrite of the Foundation framework (2022)

infoq.com

21–30 of 402 posts

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#23

I don't know Swift too well but my impression is that the support on Linux within the Foundation is not complete. (Also, is Foundation the same thing as what one might normally term a standard library? I can't tell.) Does this change imply better (eventual) support on non-Darwin systems? Or maybe I've misread it and the change is unrelated.

> my impression is that the support on Linux within the Foundation is not complete

It is not, but it's like 95% of the way there in my experience - most things that are missing are relatively recent additions that have some complex OS interactions, like filesystem I/O with language-level concurrency features.

> Does this change imply better (eventual) support on non-Darwin systems?

Yes. The non-Darwin Foundation version is already rewrite that takes a lot of effort to keep in lock-step with the closed-source Objective-C version, so unifying the implementations in Swift will both reduce the amount of maintenance effort and promote non-Darwin platorms to more of a "first-party" status.

> Also, is Foundation the same thing as what one might normally term a standard library?

It's more of a standard library++, including some things that other languages include in their standard libraries (Date/Time models) but also other things that are common to put in third-party libraries (networking, etc.). You do not need to use Foundation for basic things like arrays or concurrency that are built into the normal standard library.

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#24
post #18

Todd, you owe me $20. (Todd said this would never happen) Also, this is great news, and it will be interesting to see what kind of real-world changes in performance this has.

I really should have started using Long Bets years ago. Ten years ago a “Tanya” told me she would never use an ebook to read literature. I’m pretty sure if I went to her house today I’d find 2. In fact I may be the only person I know who doesn’t own one (not wanting one and being fundamentally against them are two different things). That’s the most memorable but I’ve had these sorts of “over my dead body” conversatio…

Maybe Tanya reads a lot of PDF as kind of default format for all kinds of technical things and very common format for downloadable ebooks. AFAIK ebook readers are terrible in pdf rendering.

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#26
post #8

Todd, you owe me $20. (Todd said this would never happen) Also, this is great news, and it will be interesting to see what kind of real-world changes in performance this has.

Things will get even slower.

Just to explain why Objective C code, in practice, is not especially fast:

You generally make the choice between writing something in pure C, which gives you plenty of performance but little safety, or using Objective C classes and methods, which gives you plenty of safety but you're paying the price for dynamic dispatch (objc_msgSend) and pointer indirections all the time.

Swift makes it easier to eliminate things like dynamic dispatch while still keeping the safety. So it should be normal and expected that a rewrite from Objective C to Swift would result in a speedup (and increase in code size).

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#27
post #20

I am pretty certain that most of high level use cases for Rust could be replaced with Swift, with increased developer velocity, if Swift was actually cross platform. And that's coming from a Rust fan. It will be interesting to see how effective this rewrite is.

I would love to be able to write cross-platform desktops apps in Swift. The language isn't perfect of course but I enjoy it a lot more than the alternatives I've tried.

That possibility is still a ways down the road of course but Foundation getting a cross platform rewrite is a nice step in that direction.

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#28

I don't know Swift too well but my impression is that the support on Linux within the Foundation is not complete. (Also, is Foundation the same thing as what one might normally term a standard library? I can't tell.) Does this change imply better (eventual) support on non-Darwin systems? Or maybe I've misread it and the change is unrelated.

> my impression is that the support on Linux within the Foundation is not complete It is not, but it's like 95% of the way there in my experience - most things that are missing are relatively recent additions that have some complex OS interactions, like filesystem I/O with language-level concurrency features. > Does this change imply better (eventual) support on non-Darwin systems? Yes. The non-Darwin Foundation vers…

> complex OS interactions, like filesystem I/O with language-level concurrency features.

Do you mean like io_uring? That wouldn't be too surprising. Even Go doesn't have that in the standard library yet.

> so unifying the implementations in Swift will both reduce the amount of maintenance effort and promote non-Darwin platorms to more of a "first-party" status.

That's what I was hoping for. Thanks!

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#29
post #20

I am pretty certain that most of high level use cases for Rust could be replaced with Swift, with increased developer velocity, if Swift was actually cross platform. And that's coming from a Rust fan. It will be interesting to see how effective this rewrite is.

Afaik Swift is pretty close to using Rc and Arc everywhere. Does swift do some more escape analysis than Rust?

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#30
post #8

Todd, you owe me $20. (Todd said this would never happen) Also, this is great news, and it will be interesting to see what kind of real-world changes in performance this has.

Things will get even slower.

What has been getting slower for you?
Post reply on HN