News for hackers. Stuff that matters.
Re:Apple is rewriting Foundation in Swift by baby on Sunday May 21, 2023 @11:46PM (#36027223)
If they had waited a little bit Rust would have been a great option. That's a shame.
Re:Apple is rewriting Foundation in Swift by masklinn on Monday May 22, 2023 @12:30AM (#36027472)
Unlikely, rust is rather inconvenient for gui allocations.

And not at all compatible or easily bridgeable with obj-c, which was not optional.

Re:Apple is rewriting Foundation in Swift by irrational on Monday May 22, 2023 @12:00AM (#36027314)
Is there a way they could have known that?
Re:Apple is rewriting Foundation in Swift by dwaite on Monday May 22, 2023 @04:29AM (#36028783)
Not really. The two are somewhat sister languages, but they have been syntax-optimized toward completely different focuses.

Swift for example defaults to copyable value types and reference types that are refcounted because that is what is most often needed for evented application code, while Rust defaults to non-copyable objects (with wrappers for things like reference counting) because of its systems development focus.

Swift also had a hard requirement of a decade of co-existance with Objective-C. A significant number of Swift types toll-free bridge with objc (and corefoundation) alternatives, and that had a considerable impact on the standard library. Their base library would be different from Rust's "std" due to needing different implementations of strings, vectors, dicts and so on.

The two do take quite a bit of inspiration from one another, and will gradually grow to support an ever-larger overlapping set of use cases, but the design constraints of the existing language will still mean that one or the other is better for a specific task.

Re:Apple is rewriting Foundation in Swift by o1y32 on Monday May 22, 2023 @05:58AM (#36029305)
No, that's not possible. Just one example -- In Rust/C++, developer is responsible for managing the memory, while in Java/Swift etc the language does most of the work for you. This alone can fundamentally change many aspects of language design and mean completely different experience for developers
Re:Apple is rewriting Foundation in Swift by baby on Monday May 22, 2023 @01:51PM (#36034464)
Ah I see, I didn't know Swift was garbage collected. That makes sense.

EDIT: wait, I'm reading that swift does not have a garbage collector. I guess I don't see how it differs from Rust then.

EDIT2: ah I see, everything's a smart pointer basically and memory's released at the end (RAII-style), whereas Rust has the borrow checker (but it's still RAII-style). I guess both implement RAII ideas, but Rust seems to do it at compile time and Swift at run time.