News for hackers. Stuff that matters.
Re:Apple is rewriting Foundation in Swift by thrwawy74 on Sunday May 21, 2023 @10:46PM (#36026875)
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 to build something in Apple's ecosystem.
Re:Apple is rewriting Foundation in Swift by lyu07282 on Sunday May 21, 2023 @11:00PM (#36026969)
If they just had a proper cross platform standard library and package manager it might be more successful, it is a pretty cool language. But the north Korean esque closed apple ecosystem makes that impossible, all of that is intentional.
Re:Apple is rewriting Foundation in Swift by pilif on Sunday May 21, 2023 @11:08PM (#36027015)
The package manager has been open source, cross platform and available since pretty much from the start.

The standard library is becoming cross-platform as we discuss it here.

Re:Apple is rewriting Foundation in Swift by realusername on Monday May 22, 2023 @03:42AM (#36028497)
> The standard library is becoming cross-platform as we discuss it here.

I'd argue that it's too late already, the ship has sailed, Swift is heading the same way as C#.

Re:Apple is rewriting Foundation in Swift by qaq on Monday May 22, 2023 @04:37AM (#36028818)
Is there an alternative with similar features and ergonomics? I am def. not aware of one.
Re:Apple is rewriting Foundation in Swift by realusername on Monday May 22, 2023 @05:26AM (#36029089)
For which purpose? It depends what you want to do with it.
Re:Apple is rewriting Foundation in Swift by qaq on Tuesday May 23, 2023 @09:04AM (#36043663)
Well lang features do not really depend on the purpose the 3d party libs do. Let's say the purpose is web services.
Re:Apple is rewriting Foundation in Swift by realusername on Tuesday May 23, 2023 @10:29AM (#36044849)
I doubt the web story in swift is that strong anyways, I'd pick python, ruby or php.
Re:Apple is rewriting Foundation in Swift by ohgodplsno on Monday May 22, 2023 @09:37AM (#36031313)
I'm having a hard time seeing Swift becoming a well-respected and easily considered language for your next project. The sheer lack of anything outside of what Apple has made already makes it a non starter. In comparison, .Net is absolutely amazing.
Re:Apple is rewriting Foundation in Swift by nequo on Sunday May 21, 2023 @11:16PM (#36027062)
Why is it not better for Apple to make Swift truly cross-platform?

Is it just that the maintenance cost is not worth it? Or would it threaten its ecosystem in a way that I don't understand?

It would seem that making Swift cross-platform would make Apple's ecosystem more accessible to developers. The barrier to entry would be lower if developers only needed to learn the APIs and not a whole new language and its tooling too. This would help the ecosystem stay healthy for a longer time.

Re:Apple is rewriting Foundation in Swift by w10-1 on Sunday May 21, 2023 @11:34PM (#36027165)
The Swift compiler and standard library are pretty tightly linked. The Swift type system is getting pretty complicated already, handling a whole range of lifetimes, async, the combination of protocols, generics, existentials, etc. with some magic handling for arrays and maps in the library. So the cost of cross-platform effort would be significant.

The greatest barrier to entry is XCode. It's archaic, impossible to extend, and has a very wide surface that would overwhelm any development team.

(Java works fine on macOS, but developers want to deploy to iOS.)

Re:Apple is rewriting Foundation in Swift by delta_p_delta_x on Monday May 22, 2023 @12:29AM (#36027466)
.NET MAUI[1] and AvaloniaUI[2] run on iOS pretty well, and one can use Rider/VS Code/other editors to develop apps.

[1]: https://learn.microsoft.com/en-us/dotnet/maui/ios/cli

[2]: https://docs.avaloniaui.net/tutorials/developing-for-mobile/...

Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:25AM (#36028409)
Hope this keeps getting investment and support by Microsoft. Choice and competition are very welcome, even though i code neither iPhone Apps nor C# ATM.
Re:Apple is rewriting Foundation in Swift by ohgodplsno on Monday May 22, 2023 @09:39AM (#36031327)
Kotlin/Native deploys and works on iOS, but due to Apple holding back on opening up Swift, it has to do everything through ObjC interop. But make no mistake, to Apple, that's a feature: if other languages have a hard time integrating in their ecosystem, they'll go away.
Re:Apple is rewriting Foundation in Swift by pca006132 on Sunday May 21, 2023 @11:26PM (#36027119)
I thought Apple just wants to be different, and making Switft not cross platform can make porting software on Apple ecosystem harder...
Re:Apple is rewriting Foundation in Swift by MattRix on Monday May 22, 2023 @12:27AM (#36027451)
Apple’s problem has never been the “barrier to entry”. They know developers will make apps for their platform no matter what. If Swift becomes more universal it makes it easier for Apple developers to also develop for Android (etc) which Apple would see as a bad thing.
Re:Apple is rewriting Foundation in Swift by worrycue on Monday May 22, 2023 @01:07AM (#36027670)
Wouldn't developers also develop for Android no matter what?
Re:Apple is rewriting Foundation in Swift by qwytw on Monday May 22, 2023 @02:11AM (#36028009)
There are still some iOS (and especially macOS) specific apps because the cost of porting a native app is not insignificant.
Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:26AM (#36028416)
Some Apps are exlusive to iOs and some start out there, because that is where the money is.
Re:Apple is rewriting Foundation in Swift by raydev on Monday May 22, 2023 @10:00PM (#36038928)
Not as long as iOS users spend more money on average.
Re:Apple is rewriting Foundation in Swift by saagarjha on Monday May 22, 2023 @02:24AM (#36028098)
That has only really been the case for iOS and even then it’s not necessarily a given.
Re:Apple is rewriting Foundation in Swift by hedgehog on Sunday May 21, 2023 @11:23PM (#36027100)
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.
Re:Apple is rewriting Foundation in Swift by singularity2001 on Monday May 22, 2023 @12:58AM (#36027624)
Same, I find swift so much more ergonomic and beautiful than rust, but the development story outside (and inside) of xcode is just ugly
Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:16AM (#36028364)
AppCode being sunsetted by Jetbrains made me a little sad. Not coding in the Apple ecosystem anymore. Out of IntelliJ, Visual Studio and XCode, it made the worst impression on me
Re:Apple is rewriting Foundation in Swift by frizlab on Wednesday May 24, 2023 @12:38PM (#36060608)
Swift is fully compatible with Visual Studio for those who prefer it. They have an official extension which works very well https://www.swift.org/blog/vscode-extension/

(Also, it’s Xcode)

Re:Apple is rewriting Foundation in Swift by threeseed on Monday May 22, 2023 @01:15AM (#36027714)
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 by shagie on Sunday May 21, 2023 @11:04PM (#36026994)
IBM briefly did a "swift on the server" though at the beginning of 2020 IBM was no longer interested, but the page is still up. https://developer.ibm.com/languages/swift/

2016: https://9to5mac.com/2016/02/22/ibm-swift-cloud-kitura/

2016: https://www.infoq.com/presentations/swift-server/

2020: https://www.infoq.com/news/2020/01/ibm-stop-work-swift-serve...

You can run it in docker: https://hub.docker.com/_/swift

Re:Apple is rewriting Foundation in Swift by awill on Sunday May 21, 2023 @11:19PM (#36027075)
This was so predictable. I remember those articles, and thought "Gee, IBM doesn't know what they're doing, they're just jumping on random bandwagons"
Re:Apple is rewriting Foundation in Swift by artificialLimbs on Monday May 22, 2023 @12:46AM (#36027564)
Still waiting on Apple Silicon DB2 driver. Any day now, I know it!
Re:Apple is rewriting Foundation in Swift by yieldcrv on Monday May 22, 2023 @02:24AM (#36028095)
> but the page is still up.

for now

just saw an article about IBM deleting most of their website because its a mess. It was some linkedin developer's post.

Re:Apple is rewriting Foundation in Swift by ayewo on Monday May 22, 2023 @05:24AM (#36029075)
Link to the recent post about house cleaning to remove 80% of IBM's website (though on Twitter not LinkedIn).

https://twitter.com/bryanfcasey/status/1659941975519375360

Re:Apple is rewriting Foundation in Swift by carbocation on Sunday May 21, 2023 @10:53PM (#36026925)
As someone who mostly writes Go, I enjoy Swift the language. I am guessing that your concerns are centered on Swift the ecosystem? (E.g., it's only used for Apple things, so there are probably not libraries for Thing X.) If so that makes total sense to me. If not, I'd be interested to hear more.
Re:Apple is rewriting Foundation in Swift by GeekyBear on Sunday May 21, 2023 @11:21PM (#36027091)
> 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.

Re:Apple is rewriting Foundation in Swift by kitsunesoba on Sunday May 21, 2023 @11:31PM (#36027156)
I think many also find its syntax more approachable compared to that of Rust. It's got a lot of bells and whistles, but newcomers don't have to use them right away and can pick up more advanced bits as they become comfortable with doing so.
Re:Apple is rewriting Foundation in Swift by GeekyBear on Sunday May 21, 2023 @11:42PM (#36027203)
> I think many also find its syntax more approachable compared to that of Rust.

Chris Lattner (of LLVM fame) did design the language with the goal of hiding complexity until it is needed.

> The concept of progressive disclosure in Swift, where you can start with something very simple and then learn complexity as you go, was totally driven by making it teachable. I personally spent a lot of time trying to make sure that the introduction to Swift could just be print("Hello World"). No semicolons, no \ns, none of that public static void main stuff. Making it simple and approachable was a strong goal, and not in a weird way where in a teaching environment there is this “Swift Prime” language that’s similar but different.

https://oleb.net/blog/2017/06/chris-lattner-wwdc-swift-panel...

Re:Apple is rewriting Foundation in Swift by noisy_boy on Monday May 22, 2023 @12:15AM (#36027397)
I did the Swift tutorial a short while ago and it was a breeze. I found it more approachable than Rust (I do like Rust).
Re:Apple is rewriting Foundation in Swift by kevingadd on Sunday May 21, 2023 @11:23PM (#36027102)
From what I've seen the ref counting can cause a big performance hit. Maybe this has improved in the last couple years?
Re:Apple is rewriting Foundation in Swift by GeekyBear on Sunday May 21, 2023 @11:34PM (#36027167)
> 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.

Re:Apple is rewriting Foundation in Swift by comex on Monday May 22, 2023 @12:14AM (#36027391)
But it's mostly replacing Objective-C code which was already not particularly fast – as opposed to the C++ or C code used more often in performance- or memory-sensitive areas.

My experience with Swift is somewhat limited, because every time I've tried to use it, I've run into glaring performance issues and had to switch language. It might be reasonably performant compared to Go or .NET, but it's nothing like Rust.

Re:Apple is rewriting Foundation in Swift by trinix912 on Monday May 22, 2023 @12:43AM (#36027545)
What kind of stuff were you doing in Swift to notice performance issues? I've been developing macOS and iOS apps for a while now and it doesn't seem much slower than Objective-C.
Re:Apple is rewriting Foundation in Swift by aatd86 on Monday May 22, 2023 @01:32AM (#36027785)
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 by GeekyBear on Monday May 22, 2023 @01:59AM (#36027928)
It was discussed here when they decided their networking stack in Go would need to be rewritten for performance reasons, and banned the future use of Go for Fuchsia system components.

https://news.ycombinator.com/item?id=22409838

Re:Apple is rewriting Foundation in Swift by stevefan1999 on Monday May 22, 2023 @01:08AM (#36027680)
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 the time you rather deal with I/O bound problem more than an additional atomic increment operation. Modern processor is fast enough to deal with them in few cycles in around the order of 10 nanoseconds

Re:Apple is rewriting Foundation in Swift by GeekyBear on Monday May 22, 2023 @01:38AM (#36027819)
> Reference counting is slow because it has an additional increment/decrement operator on each lifetime of a scope.

On Apple Silicon this particular use case saw a large optimization compared to Intel.

> fun fact: retaining and releasing an NSObject takes ~30 nanoseconds on current gen Intel, and ~6.5 nanoseconds on an M1

Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @01:31AM (#36027781)
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 by plorkyeran on Monday May 22, 2023 @02:01AM (#36027947)
IME Swift’s refcounting is either incredibly inconsequential or a dealbreaker, with very little in between. They’ve done a very good job of optimizing it to the point where it’s barely measurable even in perf sensitive code… until you hit the scenarios where it completely murders performance and there’s nothing you can do about it.

Hopefully the upcoming ownership functional will help in those cases.

Re:Apple is rewriting Foundation in Swift by Someone on Monday May 22, 2023 @03:38AM (#36028476)
* * *
Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @05:11AM (#36029010)
On apple hardware, uncontended refcounting (swift or objc) has the same perf as non-atomic refcounting. The cost exists, but it isn't terrible, once there's contention between threads the perf drops through the floor. The real killer is there are a bunch of places where the swift evaluation model means they're forced to ref churn, which comes up 100% typical workloads like the million triangle objects in my swift raytracer, all being hit by numerous threads :D
Re:Apple is rewriting Foundation in Swift by dralley on Monday May 22, 2023 @01:27AM (#36027756)
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 by GeekyBear on Monday May 22, 2023 @01:50AM (#36027878)
> it seems like they may have spent a fair bit of effort optimizing Apple Silicon for it

According to information released when the M1 came out: retaining and releasing an NSObject takes ~30 nanoseconds on current gen Intel, and ~6.5 nanoseconds on an M1

Re:Apple is rewriting Foundation in Swift by fulafel on Friday May 26, 2023 @04:03PM (#36088894)
It's good to reduce the cache hot best case time of course but isnt the more fundamental sin of RC in the extra read/write memory traffic, cache footprint and cross core cache line ping pong when incrementing object refcount fields.

(or if going with BRC, correspondingly there shouldn't be a advantages for this custom CPU feature)

Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @06:14AM (#36029445)
Reference counting on Objective-C was plan B, after the failure of implementing a safe tracing GC in a language with C's semantics.

So they went with plan B, having the compiler automate the retain/release messages used by the Cocoa framework.

Everywhere else in Objective-C, the memory is still manually managed, or via memory pools.

Re:Apple is rewriting Foundation in Swift by cellularmitosis on Monday May 22, 2023 @01:21AM (#36027738)
> 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 by aatd86 on Monday May 22, 2023 @01:30AM (#36027768)
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 by pkulak on Monday May 22, 2023 @02:34AM (#36028153)
Ref-counting GC is pretty slow. It’s great for avoiding stop-the-world pauses, which can be really important for UI stuff like what Swift is used for, but you won’t win any throughput awards.
Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:36AM (#36028470)
So well engineered for its use case. Was Go optimized for throughput?
Re:Apple is rewriting Foundation in Swift by retendo on Monday May 22, 2023 @03:47AM (#36028530)
Swift doesn't have a GC. The automatic reference counting is a feature that just inserts retain/release statements at compile time, so there is no additional process that handles that. I would suspect that the performance hits originate from other things.
Re:Apple is rewriting Foundation in Swift by cellularmitosis on Monday May 22, 2023 @07:54AM (#36030191)
I don’t see a lot of utility in policing an overly narrow definition of what constitutes garbage collection.
Re:Apple is rewriting Foundation in Swift by frizlab on Wednesday May 24, 2023 @12:41PM (#36060649)
ARC is a type of GC though.
Re:Apple is rewriting Foundation in Swift by brink on Sunday May 21, 2023 @10:58PM (#36026952)
Seems a lot of people feel the way you do. I had to make something using swift once, and could barely find a community to help me decipher the cryptic swift documentation centered around their coreml library. Apple is keeping Swift on life support, imo.
Re:Apple is rewriting Foundation in Swift by blululu on Sunday May 21, 2023 @11:44PM (#36027216)
CoreML is a bit of an exceptional challenge beyond just Swift. Admittedly it could really use a lot more documentation from Apple, but it would be unfair to judge swift based on an uncommon and under documentated library (I suspect that it would get a lot more use if it were not so hard to set up).
Re:Apple is rewriting Foundation in Swift by 29athrowaway on Sunday May 21, 2023 @10:55PM (#36026937)
There was a lot of excitement when it first came out.

I tried Swift for Linux, and soon realized it was a meh experience (NS this, NS that... NextStep is still there) and switched back to Rust.

It could have been a strong Rust alternative.

Re:Apple is rewriting Foundation in Swift by dwaite on Monday May 22, 2023 @04:30AM (#36028788)
That is partly what this article is about - a swift-native set of foundation modules.
Re:Apple is rewriting Foundation in Swift by 29athrowaway on Monday May 22, 2023 @06:56PM (#36037750)
Yeah but I am too invested in Rust right now
Re:Apple is rewriting Foundation in Swift by vxNsr on Sunday May 21, 2023 @10:56PM (#36026938)
While generally true that you’re not gonna find swift anywhere else, this company[0] is making their browser cross platform and using swift as the language. Apparently there’s a proof of concept runtime for windows that they’re actively working on.

[0] https://arc.net/

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.

Re:Apple is rewriting Foundation in Swift by djha-skin on Sunday May 21, 2023 @11:49PM (#36027238)
There's not even anything technically interesting about the language. Reference counting? Really? We have so much more than that and you just went with reference counting. Ugh
Re:Apple is rewriting Foundation in Swift by zarzavat on Monday May 22, 2023 @12:01AM (#36027321)
What would you use instead of ref counting? Swift is an embedded language for Apple’s own chips, they can optimize the hell out of refcounting at silicon level.
Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @02:05AM (#36027970)
There really is only so much you can do - especially once you've got refcount churn on objects being used across multiple threads. Swift's refcounting can get truly annoying at times.
Re:Apple is rewriting Foundation in Swift by pkulak on Monday May 22, 2023 @02:37AM (#36028173)
Modern, state-of-the-art, generational GC? Not being snarky, that’s literally the comparison.
Re:Apple is rewriting Foundation in Swift by zarzavat on Monday May 22, 2023 @06:10AM (#36029415)
There was never any way to implement a modern GC while keeping compatibility with Objective-C, which was the primary design goal of Swift.

Apple had a bad experience with GC in ObjC with libauto and learned their lesson that C and GC just don’t mix. You can never have a truly modern GC in C, because C cannot provide any of the guarantees that a GC needs to move objects around.

Using a modern GC entails sealing the language off in a bubble. Since Swift is mostly used to interface with system frameworks, you would end up paying a cost when interfacing with the system frameworks written in ObjC, making your modern GC useless most of the time.

Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @02:03AM (#36027963)
> There's not even anything technically interesting about the language

It's a modern statically compiled language with complex generics, that supports providing a generic interfaces in libraries with retaining ABI compatibility. Which no other modern "system" language supports. That's fairly technically interesting to me.

> We have so much more than that and you just went with reference counting

Like what?

The options for memory safe shared ownership are refcounting or GC.

Assuming you're talking about rust, that's just C++: object lifetime is lexical, and if you need it to last longer you have to use Arc/Rc/shared_ptr. The purpose of the lifetime and borrow checkers is to ensure exclusive access, and reduce the copy/destruction churn that you get from the C++ model (a hypothetical C++ that only allows the use of unique_ptr instead of raw pointers - obviously C++'s type system and approach to memory safety is not a Good Thing).

But it's important to realize rust did not create a new solution to object lifetime management for shared objects.

It's also important to realize that rust was designed in an environment where there was no existing code to interoperate with, whereas Swift was designed to work with the existing Darwin APIs and objective-c which are all refcounted. So even if no refcounting was the goal you'd end up with a new language, designed for a specific environment, and the default behaviour would not be correct.

Now that the language is more established, and it's less critical for every part of the language to have objc interop they are working on pure ownership semantics, for the same reason as rust: it saves copies without requiring a refcount[1]

[1] https://github.com/apple/swift/blob/main/docs/OwnershipManif...

Re:Apple is rewriting Foundation in Swift by blululu on Sunday May 21, 2023 @11:53PM (#36027257)
Totally valid point that swift is only useful for developing for Apple products, but this same criticism also applies more or less to Kotlin on Android. If you are dealing with iOS it is a joy compared to objective C. I would also add that it is a really nice language in general that is modern, expressive and general ergonomic.
Re:Apple is rewriting Foundation in Swift by chii on Monday May 22, 2023 @12:03AM (#36027329)
> this same criticism also applies more or less to Kotlin on Android.

i think kotlin has more use outside compared to swift.

But a language has to start somewhere, so i wouldn't hold it against swift. It's a fairly well done language regardless, and nothing apple specific about it tbh (which are all just libraries).

Re:Apple is rewriting Foundation in Swift by Illniyar on Monday May 22, 2023 @12:37AM (#36027517)
Kotlin wasn't developed for Android. And can be run anywhere.

It was JetBrains pet project to fix archaic stuff in Java without making a Scala. It was designed from the get go for a wide base (as wide as java).

I'm not sure how it became Android's main target, but I doubt it was the original purpose.

Re:Apple is rewriting Foundation in Swift by jszymborski on Monday May 22, 2023 @12:44AM (#36027547)
Further to that point, Kotlin mainly targets the JVM (which can run pretty much everywhere), but also can be compiled to JavaScript, LLVM, and a bunch of other targets.

Honestly the only times I've evaluated Kotlin for personal projects was bc of that flexibility.

Re:Apple is rewriting Foundation in Swift by singularity2001 on Monday May 22, 2023 @01:01AM (#36027645)
recently kotlin can even be used to compile to native and wasm, but gradle makes it almost less usable than swift
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @02:03AM (#36027957)
With various levels of implementation quality, Kotlin/Native had to be rebooted, on JS it hardly offers anything better than TypeScript, on the JVM it is mostly used by Android shops anyway.
Re:Apple is rewriting Foundation in Swift by radley on Monday May 22, 2023 @12:48AM (#36027577)
I think everyone jumped from Java to Kotlin due to Oracle suing Google over Java in Android. It also provided a huge opportunity to be more deliberate since Android was maturing.
Re:Apple is rewriting Foundation in Swift by nazgulsenpai on Monday May 22, 2023 @02:13AM (#36028028)
Oracle sued Google over the Android's implementation of Java's API. Kotlin still uses those APIs as it is compiled to Java bytecode on Android.
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @06:08AM (#36029396)
That is an urban myth.

If that was the case, they would have adopted Dart instead of keeping an high dependency on the Java ecosystem for Android.

Android Studio, Gradle, Kotlin compiler, the libraries that Android depends on from Maven Central, all Java.

Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @02:01AM (#36027944)
Because Google and JetBrains are in bed together in what concerns Android development tooling.

Try to use Kotlin without the Android ecosystem, it is just syntax sugar for the JVM.

Re:Apple is rewriting Foundation in Swift by philwelch on Monday May 22, 2023 @11:42AM (#36032885)
Java is just syntax sugar for the JVM too, it's just that Kotlin is a better one.
Re:Apple is rewriting Foundation in Swift by deaddodo on Monday May 22, 2023 @02:39AM (#36028189)
> Kotlin wasn't developed for Android. And can be run anywhere.

I agree and would go so far as to say that Dart is a better comparison to Swift than Kotlin is.

Re:Apple is rewriting Foundation in Swift by balder1991 on Monday May 22, 2023 @03:04AM (#36028306)
It was adopted on Android quite fast after Jetbrains made the integration in Android Studio almost flawless, partly because back then the Android runtime was stuck on the Java 6 syntax plus some syntax sugar that the IDE provided to mimic lambda functions.

It helped a lot that I think Jetbrains took advantage of all they could to make development in Kotlin very smooth, I remember back then people joked how Kotlin worked so flawlessly on Android Studio almost like it was the main language while on Xcode Swift was slow, the highlight would stop working constantly, refactoring was not supported, often indexing the project would hang forever etc.

Re:Apple is rewriting Foundation in Swift by philwelch on Sunday May 21, 2023 @11:56PM (#36027279)
I thought Kotlin was pretty widely used as a Java alternative on the backend
Re:Apple is rewriting Foundation in Swift by rahmeero on Monday May 22, 2023 @12:03AM (#36027330)
An example is smart contracts on the Corda blockchain, which is programmed in Kotlin. It may be me, but I have seen more Kotlin outside of Android than on it.
Re:Apple is rewriting Foundation in Swift by fnord77 on Monday May 22, 2023 @12:02AM (#36027323)
Kotlin seems kinds of pointless with the features in newer Java versions
Re:Apple is rewriting Foundation in Swift by doyouevensunbro on Monday May 22, 2023 @12:35AM (#36027508)
Just looking at Java’s upcoming string interpolation makes me so happy I moved to Kotlin years ago.

https://openjdk.org/jeps/430

Re:Apple is rewriting Foundation in Swift by d3nj4l on Monday May 22, 2023 @12:30AM (#36027477)
No amount of lipstick on the java pig will make it as ergonomic to use by default as kotlin.
Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:34AM (#36028454)
Harsh but have to agree.
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @06:09AM (#36029405)
It is enough that it is the Java Virtual Machine, not Kotlin Virtual Machine.

Hence why Kotlin only really matters on Android.

Re:Apple is rewriting Foundation in Swift by fbdab103 on Monday May 22, 2023 @01:08AM (#36027677)
Would Java had advanced without Kotlin on its doorstep?
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @06:10AM (#36029413)
Yes, because Kotlin hardly matters in regards to the JVM.
Re:Apple is rewriting Foundation in Swift by fnord77 on Monday May 22, 2023 @05:30PM (#36036974)
Lots of languages are converging on features and idioms. Scala and Haskell have had an influence on New Java too.
Re:Apple is rewriting Foundation in Swift by stevefan1999 on Monday May 22, 2023 @01:00AM (#36027642)
At least I got to integrate Spring Boot well with Kotlin. Same goes for writing Minecraft mods.
Re:Apple is rewriting Foundation in Swift by rvz on Monday May 22, 2023 @12:51AM (#36027593)
> 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

Re:Apple is rewriting Foundation in Swift by iknowstuff on Monday May 22, 2023 @01:01AM (#36027649)
The who
Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @01:33AM (#36027790)
Yet another chrome wrapper, but with VC funding.
Re:Apple is rewriting Foundation in Swift by rvz on Monday May 22, 2023 @01:52AM (#36027886)
And?

Brave (VC funded) is also a Chromium wrapper and Edge (Microsoft owned) is also one as well and both of the somehow managed to beat Firefox in usage. So what is you point?

Chrome and its derivatives is the reason why browsers like Firefox is failing to keep up and continues to lose users.

Using anything other than Chrome for a modern web browser is a losing battle. (Brave already tried that with Firefox and quickly switched to Chrome)

Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @05:05AM (#36028972)
> And?

I was answering a question asking what it was. Are you saying my answer was wrong?

> Brave (VC funded) is also a Chromium wrapper and Edge (Microsoft owned) is also one as well and both of the somehow managed to beat Firefox in usage.

Well that's just false.

Firefox has 7.7% marketshare.

Brave comes in at less than 1 tenth of a percent.

Edge, does better after all it is the _default_ browser on the most popular desktop OS by a massive margin. It gets <6% of the market.

So Firefox has greater market share than both of those combined.

> Chrome and its derivatives is the reason why browsers like Firefox is failing to keep up and continues to lose users.

You mean Chrome. None of the "derivatives" other than Edge (due to default browser syndrome) and Opera (which gets 2%) have any marketshare, and neither does anything to prevent Google from doing whatever it wants.

> Using anything other than Chrome for a modern web browser is a losing battle.

The reason is very very simple: Chrome is the modern IE, and making content that only works in Chrome (or wrappers) is considered acceptable by the same mediocre developers that made IE only sites a decade ago.

On the other hand, I get where you are coming from: people also said the same thing about using anything other than IE.

Re:Apple is rewriting Foundation in Swift by o1y32 on Monday May 22, 2023 @06:03AM (#36029358)
Everyone knew IE was going away. Chrome is not, from what we can see, and is not going away any time soon. If anything, Chrome/Chromium-based browsers are eating other browsers' lunch, just look at the numbers. I absolutely hate Chrome doing their own non-standard things, but you live in a special bubble.
Re:Apple is rewriting Foundation in Swift by olliej on Monday May 22, 2023 @03:09PM (#36035400)
> Everyone knew IE was going away.

No. That's an exciting fictional world in which you live, and was not the case. Even in the last years preceding Google's chrome release and massive marketing push, when Firefox and Safari were taking "significant" marketshare, it was assumed IE would be forever, and IE-only sites were still common (and the norm in "enterprise" software).

There is literally no difference between a developer that says everyone uses/should use chrome, and a developer a decade ago saying the same thing about IE.

Re:Apple is rewriting Foundation in Swift by rvz on Monday May 22, 2023 @02:34AM (#36028154)
You know who. [0]

[0] https://arc.net

Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:42AM (#36028494)
The band?

Sorry for the joke, know it is frowned upon, did it anyway.

Re:Apple is rewriting Foundation in Swift by ohgodplsno on Monday May 22, 2023 @09:44AM (#36031389)
The Browser Company is absolutely no one. They're barely more influent than me creating a repo on github, and that kind of impact is pretty damn low as is. They're a 0.000% browser share company that runs a tight marketing campaign of only inviting tech influencers to their browser. Mind you, said browser has good ideas, great ones even. But overall, they're absolutely no one.

iOS/macOS devs use Swift on other platforms because it's the only language they know, yeepidodadey. Ignore the fact that 99% of their project is cinterop with Chromium

Re:Apple is rewriting Foundation in Swift by brundolf on Monday May 22, 2023 @01:20AM (#36027735)
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 by Grustaf on Monday May 22, 2023 @01:34AM (#36027796)
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.
Re:Apple is rewriting Foundation in Swift by deanCommie on Monday May 22, 2023 @01:46AM (#36027861)
Who outside of Apple is using Objective C?

That's like...Apple's whole deal. Proprietary everything top-to-bottom.

Re:Apple is rewriting Foundation in Swift by jb1991 on Monday May 22, 2023 @01:52AM (#36027888)
While it’s true that the language is really only useful on just Apple platforms, it is still quite an amazing language. I have professionally used about half a dozen languages over the last many years, written hundreds of thousands of lines each in all those languages, and swift is a true breath of fresh air. It checks all the boxes for me, very concise and elegant to write, yet very strictly statically typed. A nice upgrade to OO programming with use of protocols, with strong encouragement to use functional programming here and there as well. Runs reasonably fast, on par with Go or Java. Overall just really nice ergonomics. named parameters and a wide variety of other seemingly minor syntactical characteristics act as a meaningful upgrade to make the overall process of writing code much more enjoyable for me.

The fact that Apple provides all these incredible platform specific frameworks and libraries for graphics, audio, games, GPU kernel programming, and more, it’s just the icing.

Re:Apple is rewriting Foundation in Swift by mpweiher on Monday May 22, 2023 @02:28AM (#36028124)
> upgrade to OO programming with use of protocols

How exactly are protocols a Swift "upgrade" to OO programming? They were in Objective-C since the mid 90s, adopted by Java as interfaces, copied by C# etc.

Also, protocols in Swift have a huge performance downside, because they decided to have them work across structs and classes: if you use a protocol in a function argument, the compiler doesn't even know the size of the argument at compile time, so copying the arguments has to be dynamically dispatched unless the compiler can figure it out in an extra optimisation pass...that's not possible when doing separate compilation.

> Runs reasonably fast, on par with Go or Java.

A downgrade...particularly considering the epic compile times.

> named parameters

Also there since the 80s, in a less weird way.

https://blog.metaobject.com/2020/06/the-curious-case-of-swif...

> ...professionally used about half a dozen languages ...

What languages were those, if I may ask?

Re:Apple is rewriting Foundation in Swift by jb1991 on Monday May 22, 2023 @03:10AM (#36028341)
Strange comment. I never said that Swift invented these language features; not sure what the relevance is that many of its features have existed for a long time and some other languages also offer them. Swift ties together a lot of features that in combination make it quite enjoyable to use. It's fine if you prefer other languages, there is certainly plenty of choice. Speaking of protocols, they offer some significant differences to protocols in ObjC which are very effective for writing saner and less bug-prone code, but I don't want to expound here on all aspects of the language. (there are many other simple features that make a big difference to the coding flow; computed properties, language-level optionals and the syntax surrounding their myriad uses, the list is quite long of good features to speed up safe, productive workflows)

Never had a problem with long compile times -- once you have your initial build, 90% of the time or more the incremental build process is very fast.

The languages I used for about 15 years were ObjC, C, C++, Clojure (and other langs before that). I find Swift to be a thoughtful blend of the key features of these four languages -- each of the things I like most about those langauges are in Swift, but it's the syntax in particular that I like most.

Re:Apple is rewriting Foundation in Swift by mpweiher on Monday May 22, 2023 @05:10AM (#36029003)
> I never said that Swift invented these language features;

Hmm...not sure how else to interpret "upgrade to OO programming with use of protocols" other than that there was an upgrade to OO, and that upgrade was with the use of protocols. Now it looks like you meant an upgrade of the way protocols are used in OO, but you won't say how they Swift's protocols actually constitute an upgrade.

OK. ¯\_(ツ)_/¯

Re:Apple is rewriting Foundation in Swift by Grustaf on Monday May 22, 2023 @08:29AM (#36030542)
Protocols replace many uses of OO from objc, making code much easier to understand. In addition, swift protocols are much more powerful in almost every way.
Re:Apple is rewriting Foundation in Swift by dwaite on Monday May 22, 2023 @04:13AM (#36028668)
> How exactly are protocols a Swift "upgrade" to OO programming? They were in Objective-C since the mid 90s, adopted by Java as interfaces, copied by C# etc.

Typically you would write more protocol-oriented code - rather than using inheritance (which is mostly there for Objective-C compatibility) you define protocols and implement them for types.

This is a lot closer to traits in Rust than interfaces in Java. Among other things, a developer can define how a third party type implements a protocol they control, without subclassing or wrapping, as long as it does not require additional data.

Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @06:05AM (#36029369)
So just like lots of Objective-C code, including the old NeXTSTEP Kits?
Re:Apple is rewriting Foundation in Swift by jb1991 on Monday May 22, 2023 @06:29AM (#36029564)
Swift's protocols are an evolution of protocols in ObjC. They offer additional features to make them safer and easier to write.
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @07:28AM (#36030046)
I know both languages, did my learnings of Objective-C while porting code from NeXTSTEP into Windows 95, what additional features?
Re:Apple is rewriting Foundation in Swift by jb1991 on Monday May 22, 2023 @07:58AM (#36030220)
I won’t teach Swift here, but Google is your friend. You can start by studying all the languages differences with regards to extending existing protocols, and how optional protocol conformance and methods are handled. Swift in many ways (not just with protocols) is like a fix for many headaches that objc provided in these areas. It’s partly why Apple encourages “protocol oriented” programming in swift over “object oriented” because of how rich the feature set is compared to objc.
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @09:27AM (#36031164)
Which are basically another way to mix protocols and categories from Objective-C.

No need for Google, as mentioned, I know both languages.

As for protocols not being encouraged in Objective-C, I migth own the wrong NeXTSTEP manuals.

Re:Apple is rewriting Foundation in Swift by jb1991 on Monday May 22, 2023 @01:12PM (#36034023)
It does indeed sound like you have some very old documentation.

(as a sibling comment pointed out, swift protocols are typically used for things that in objc you would use inheritance)

Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @04:36PM (#36036388)
Old enough to have enough Objective-C protocols and categories in action.

The kind of documentation that inspired Java authors.

https://cs.gmu.edu/~sean/stuff/java-objc.html

https://en.wikipedia.org/wiki/Portable_Distributed_Objects

https://en.wikipedia.org/wiki/Distributed_Objects_Everywhere

Re:Apple is rewriting Foundation in Swift by jb1991 on Tuesday May 23, 2023 @01:25AM (#36040205)
Quite a lot has changed in objc since the nextstep days! And a lot more changed as Apple learned from that and built swift. My guess is you don’t know these languages as well as you think if you’re not clear about these differences.
Re:Apple is rewriting Foundation in Swift by ohgodplsno on Monday May 22, 2023 @09:31AM (#36031221)
>Runs reasonably fast, on par with Go or Java.

Having to deal with weakself, no reference cycles, very limited closures, having to deal with Xcode, no integration with any other IDE because Apple Apples, debatable generics, SPM, debatable cross platform abilities, fucking Tasks and Actors, SwiftUI being locked to versions of Swift, extremely limited community, few high quality open source libraries for something that only performs as well as Java is quite the hard sell.

For that price, you could also get Kotlin which fixes most of Java's problems and provides access to all the JVM as well as Kotlin/Native, with top tier DSL abilities and a really well thought out stdlib, coroutines, reified funs and much more.

Re:Apple is rewriting Foundation in Swift by frizlab on Wednesday May 24, 2023 @12:37PM (#36060591)
This comment is of very low quality. I agree with pretty much _nothing_ with it (and tbh most of it feels like trolling), but I’ll just comment on the thing where it’s obviously plainly wrong: no other IDE.

Swift has LSP integration, and has an official extension for VSCode, which works very well. They even have a blog post about it https://www.swift.org/blog/vscode-extension/

Re:Apple is rewriting Foundation in Swift by thrwawy74 on Monday May 22, 2023 @09:59PM (#36038923)
It's Microsoft's Powershell, but for Apple's OS.
Re:Apple is rewriting Foundation in Swift by pjmlp on Monday May 22, 2023 @01:59AM (#36027930)
The same appeal as .NET on the Windows ecosytem, Objective-C on NeXT/OS X, Java/Kotlin on Android (plenty of stuff that is Android only beyond the basic standard library, C++ OS specific SDKs,....

Many people are more than happy to do all their career on a specific platform.

Re:Apple is rewriting Foundation in Swift by _the_inflator on Monday May 22, 2023 @02:35AM (#36028159)
You got a point. On the other side, arguably, one could say the same about C#, JavaScript or Python.

It took real effort from Microsoft into the Open Source space to make it more widely popular. Far away from Java or JavaScript, but I see many similarities between the development and evolution of Swift and C#.

Almost everything starts as a domain specific language. Same goes for JavaScript. First browser only, then through Node, suddenly JavaScript everywhere.

Python gained massive traction through Jupyter. Before that, I found Python a clumsy alternative to JavaScript. Since then I have changed my mind. ;)

Re:Apple is rewriting Foundation in Swift by scns on Monday May 22, 2023 @03:20AM (#36028385)
Python came preinstalled on pretty much every Linux box before Jupyter IIRC.
Re:Apple is rewriting Foundation in Swift by awestroke on Monday May 22, 2023 @02:45AM (#36028219)
The appeal of swift is that it is lightyears better than ObjectiveC. To ObjC developers that are used to being treated like trash by Apple (abysmal documentation, stone age IDE and tooling etc) that's huge
Re:Apple is rewriting Foundation in Swift by iainmerrick on Monday May 22, 2023 @02:55AM (#36028266)
What’s changed there?

I do quite like Swift overall -- it’s usually terser than Obj-C and I like the much stricter and more expressive type system. But you pay for that with much longer compile times, and the tooling feels much the same (Xcode is still Xcode).

Re:Apple is rewriting Foundation in Swift by sumuyuda on Monday May 22, 2023 @02:58AM (#36028274)
Lol, Apple is still treating developers like trash, just a new language now.
Re:Apple is rewriting Foundation in Swift by lapcat on Monday May 22, 2023 @05:35AM (#36029140)
Apple's documentation was actually vastly superior before Swift. In fact, I often refer to the documentation "archive" instead of the latest docs.

The decline in the docs is due to a number of factors, but I would say mainly it's (1) the relentless annual major OS update schedule, (2) the proliferation of OS (macOS, iOS, watchOS, tvOS, xrOS?), (3) the dual language stack, (4) Apple personnel turnover.

Re:Apple is rewriting Foundation in Swift by spacemadness on Monday May 22, 2023 @11:15AM (#36032537)
Apple seems to abuse the fact that people make a living translating the lack of documentation into online courses, books, and articles. The market for this is an ongoing enabler at this point.