Live data from Hacker News

Apple is rewriting Foundation in Swift

github.com

121–130 of 263 posts

Re: Apple is rewriting Foundation in Swift

#122

I just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. I was excited for Foundation to become open-source. Using a language you'll really only find in 1 environment is a negative. I'm going to go feel ashamed for not getting excited about a language now. I should be celebrating "more languages", but Swift is just Apple. No one outside Apple chooses Shift unless they want…

My experience was the opposite, I really like Swift but its usefulness is held back by the lack of a wider community. I'm not sure if that's due to a lack of investment on Apple's part, or maybe that it lives in an unhappy compromise between C++ and Python where there's always a more mature alternative that's good enough, but the language itself is quite nice to write.

Scala is likely a big reason as well.

It is the most similar in terms of language features and style but it has access to Java's unparalleled library and tooling ecosystem.

Re: Apple is rewriting Foundation in Swift

#123

I just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. I was excited for Foundation to become open-source. Using a language you'll really only find in 1 environment is a negative. I'm going to go feel ashamed for not getting excited about a language now. I should be celebrating "more languages", but Swift is just Apple. No one outside Apple chooses Shift unless they want…

You're saying two things as if they're a contradiction, but they aren't

It's valuable to Apple to have a language perfectly tuned to their stack, as the official entrypoint to all their APIs. If you need to use those APIs, you're excited about Swift. If you don't, you aren't

Re: Apple is rewriting Foundation in Swift

#124

I just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. I was excited for Foundation to become open-source. Using a language you'll really only find in 1 environment is a negative. I'm going to go feel ashamed for not getting excited about a language now. I should be celebrating "more languages", but Swift is just Apple. No one outside Apple chooses Shift unless they want…

> just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. It's like Rust in that it offers memory safety by default without a big performance hit.

> without a big performance hit.

You might be surprised (I was). Most of the benchmarks I’ve seen place it more in the neighborhood of golang and v8, rather than the C, C++, rust neighborhood you might expect.

Another commenter in this thread highlighted that the ref-counting GC is what keeps it out of the C / Rust performance neighborhood.

Re: Apple is rewriting Foundation in Swift

#125

Earlier quoted context omitted.

> just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. It's like Rust in that it offers memory safety by default without a big performance hit.

From what I've seen the ref counting can cause a big performance hit. Maybe this has improved in the last couple years?

Apple has always been preferential to reference counting (see Objective C) and it seems like they may have spent a fair bit of effort optimizing Apple Silicon for it.

Re: Apple is rewriting Foundation in Swift

#126

Earlier quoted context omitted.

> just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. It's like Rust in that it offers memory safety by default without a big performance hit.

> without a big performance hit. You might be surprised (I was). Most of the benchmarks I’ve seen place it more in the neighborhood of golang and v8, rather than the C, C++, rust neighborhood you might expect. Another commenter in this thread highlighted that the ref-counting GC is what keeps it out of the C / Rust performance neighborhood.

I remember seeing a few benchmarks where v8 and go were competitive or sometimes even slightly more performant.

So not even sure that GC has always a perf cost is always true.

Not saying it doesn't in some cases, just so that we are clear but the truth seems to be more nuanced.

Re: Apple is rewriting Foundation in Swift

#127

Earlier quoted context omitted.

From what I've seen the ref counting can cause a big performance hit. Maybe this has improved in the last couple years?

Reference counting is slow because it has an additional increment/decrement operator on each lifetime of a scope. Add a little bit of salt to insult you need it to be atomic if you want it to run on SMP. This means for each time you have create/release the lifetime of an object you will make a lot of memory barriers, and create a lot of cache contention. But in practice the overhead is actually nought, and most of th…

Swift's refcounting is atomic (as is objc's). As long as you're not under contention most benchmarks I've seen show negligible overhead (from the addition of atomicity, the refcount overhead is still there) for uncontended access. But IME if you do have many threads walking the same data structure you end up spending stupid amounts of time fighting the refcounting. This applies even if the data structure is immutable and has guaranteed lifetime as swift's type system doesn't seem to allow that to be expressed, and as a result it seems to do a lot of ref churn we'd consider unnecessary.

Re: Apple is rewriting Foundation in Swift

#128

Earlier quoted context omitted.

From what I've seen the ref counting can cause a big performance hit. Maybe this has improved in the last couple years?

> From what I've seen the ref counting can cause a big performance hit. Apple has been writing OS components in Swift for a while now. It certainly doesn't seem to be producing the performance issues we saw when Google attempted to write components for Fuchsia in Go or Microsoft's effort to create new features for Longhorn in .NET.

Was probably due to FFI for Go I'd assume.

Do you have a reference somewhere I can read up?

Re: Apple is rewriting Foundation in Swift

#129
post #111

Earlier quoted context omitted.

> No one outside Apple chooses Shift unless they want to build something in Apple's ecosystem. “No one” Yet The Browser Company (The one that is hyping the Arc Browser) is writing their browser in Swift to support Windows. [0] which that is their main product. The Browser Company is not “No one”. [0] https://m.youtube.com/watch?v=Xa_fNuaSE_I EDIT: So this video doesn't show someone choosing Swift outside of Apple and…

The who

Yet another chrome wrapper, but with VC funding.

Re: Apple is rewriting Foundation in Swift

#130

I just... completely don't understand the appeal of Swift beyond it being Apple's in-house language. I was excited for Foundation to become open-source. Using a language you'll really only find in 1 environment is a negative. I'm going to go feel ashamed for not getting excited about a language now. I should be celebrating "more languages", but Swift is just Apple. No one outside Apple chooses Shift unless they want…

Even if it was a 100% Apple language, that would still be quite relevant. Apple's devices are pretty pervasive, especially among the well off.
Post reply on HN