Live data from Hacker News

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

infoq.com

331–340 of 402 posts

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

#331
post #309

Earlier quoted context omitted.

Swift will never win against Rust for a much simpler reason: performance. Invariably, rust is chosen where performance is critical, and Swift’s reference counting GC ensures it will never compete with Rust in those scenarios.

Slight correction: Swift‘s ARC is not a GC (the compiler just inserts retain/release calls where it’s necessary), and one can write very performant code by steering clear of reference counted types, and Objective-C types (dynamic dispatch is really slow). Value types with copy-on-write shouldn’t impose much overhead. Automatic inlining is progressing nicely AFAIK, and recently introduced concurrency can collapse call…

> dynamic dispatch is really slow

This is false. People believe it on faith without measuring:

https://mikeash.com/pyblog/friday-qa-2016-04-15-performance-...

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

#332

Who else remembers when they re-implemented the (at the time version of) the Foundation framework in Java for WebObjects? That was, what, 1998? Right around when NeXT got re-absorbed by Apple, not sure if the rewrite was started before or after. https://developer.apple.com/library/archive/documentation/Le... https://en.wikibooks.org/wiki/WebObjects/Overview/Objective-... Those were the days! Actually kind of amazing…

From the day I realised that, I’ve never ceased to be amazed by how many things have come from Next or were derived from it. I find it quite astounding.

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

#333
post #147

Earlier quoted context omitted.

I watched a Rust intro video recently that provided a perspective I liked, so I’ll share that here: MS, Apple, Google (and more) all relied heavily on C for low level code that needed to be as performant as possible. It turned out though that C‘s memory management is so problematic that many/most security issues are caused by it. To address that, Google invented Go, Apple made Swift, Mozilla gave us Rust etc. MS is i…

This assumes that no subsequent language comes along and steals away all the, um, seekers after novelty lately chasing Rust and Swift.

Val[0] language?

[0] https://www.val-lang.dev

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

#334

The article quotes this: > With a native Swift implementation of Foundation, the framework no longer pays conversion costs between C and Swift, resulting in faster performance. and this: > A reimplementation of Calendar in Swift is 1.5x to 18x as fast as the C one (calling from Swift in various synthetic benchmarks like creation, date calculation). First, that range of 1.5x-18x is kind of huge. Why? Second, why would…

My guess is that it isn't just down to the language, but possibly better design and perhaps better programmers. Back when I used Java as my main language I reimplemented a few projects in Java that had been C++ and sometimes got an unreasonably high performance boosts. (I'm not implying I always got things to run faster, but often). Most of those were down to:

- better understanding of the problem that needed solving, which leads to: - structuring the application so it is better suited for what it actually has to do - better choice of data structures and the algorithms that operate on them - concurrency was more easily usable, hence the code would often run on more cores

In a couple of cases I discovered that Java was inherently faster because it coincided with "what the GC likes". In some cases Java turned out to be more CPU intensive, but that this was mitigated by being able to use more cores, so the user experience was better. (There were also setbacks: anything that looks like an LRU cache for instance is not friends with the GC, and you'd have to do silly tricks with NIO ByteBuffers plus serialization and whatnot).

A lot of Apple software is buggy, badly designed junk. It used to be worse, but you can still see that a lot of their software does beginner mistakes such as blocking calls in the main event loop, resulting in "spinning ball of fail" type blockages.

Some of their system software tends to misbehave as well, consuming lots of CPU and making the fans spin up if left unaddressed. It seems to be some kind of rule that for each release there is at least one daemon that shits the bed.

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

#335
post #145

The article quotes this: > With a native Swift implementation of Foundation, the framework no longer pays conversion costs between C and Swift, resulting in faster performance. and this: > A reimplementation of Calendar in Swift is 1.5x to 18x as fast as the C one (calling from Swift in various synthetic benchmarks like creation, date calculation). First, that range of 1.5x-18x is kind of huge. Why? Second, why would…

I know nothing about their c codebase but I assume it's because when the language is hard, you tend to keep it as simple as possible. When every line stops being a foot gun, you start using optimizations you wouldn't dare before.

That's a plausible explanation which I find to have support in personal experience.

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

#337

Apple has such an unpredictable stance on software development. For example after all these years and lots of requests for such a feature it's still not possible to get notified about new reviews for your apps, but it's possible to get notified when a user edits a review after you've replied to it.

I’m not sure about macOS, but on iOS you can install the App Store Connect app (https://apps.apple.com/app/id1234793120) and then enable notifications for new reviews from there. ([app] → Notifications → Mobile → Reviews, [your initials] → Notifications → Customer Reviews)

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

#338

Is there anything genuinely innovative about Swift or is it just another "cross-platform scripting language" that I'll only see on 1 platform? The only reason I learned Powershell is because I have to admin for Windows. At least Powershell is interesting for its pipeline and object handling. I get not one spark of joy from Swift, and the comments I see are "at least we're not writing C anymore". Stockholm syndrome. S…

I've never done any Mac or iOS development and even I can see this is a strange question. I don't know why you think it's a scripting language, or how it compares in anyway to powershell?

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

#339
post #147

Earlier quoted context omitted.

I watched a Rust intro video recently that provided a perspective I liked, so I’ll share that here: MS, Apple, Google (and more) all relied heavily on C for low level code that needed to be as performant as possible. It turned out though that C‘s memory management is so problematic that many/most security issues are caused by it. To address that, Google invented Go, Apple made Swift, Mozilla gave us Rust etc. MS is i…

This assumes that no subsequent language comes along and steals away all the, um, seekers after novelty lately chasing Rust and Swift.

> and Swift

Can’t speak for Rust (but I hear that it is now quite mature -it predates Swift), but I’ve been programming Swift, since the day it was announced. In that time, the language, itself, has matured; possibly to the point that it’s starting to look a bit “Swiss army knife”-like.

I’m not exactly your typical jargonaut. I’ve been writing software since 1983. Been through a lot of changes, paradigms, and just plain old bullshit, in that time. I don’t really go for “shiny,” just because all the kids are into it, these days.

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

#340
post #41

Earlier quoted context omitted.

Yes, and it means Swift scripts and modules that don’t reference UIKit/AppKit/SwiftUI/Combine will run on Linux and possibly Windows with zero or little modification. I‘m a little sad though that they didn’t start this endeavor years ago, because IMO Rust has already built so much momentum that it will win (for the popular, medium to long term definition of „winning“).

I don't particularly care, whether or not Swift ever leaves the Apple ecosystem (like ObjC). In that domain, Rust will never "win." I think that Rust is an awesome server language, though, and I'm glad to see it gain traction. I just hope that it doesn't get trashed by a bunch of junk dependencies, written in it. I find using apps written, using hybrid systems, or PWAs, to be quite painful (on Apple devices -and that…

What is a real native app? Most operating systems have multiple graphics interfaces, ui toolkits and other abstractions with varying levels of inconsistency. They could all be driven by various languages, compiled or interpreted.
Post reply on HN