News for hackers. Stuff that matters.
Re:Swift is a more convenient Rust by afavour on Friday September 06, 2024 @07:28AM (#41465124)
As someone that’s recently been working on integrating Rust into an iOS Swift app I do agree with a lot of this. I love Rust but the more I’ve used Swift the more I find myself wishing I was just using Swift all the time.

That said, the difference between the two has a lot less to do with the language itself than the world surrounding it. You can use Swift cross platform but it’s very obvious that Apple platforms are the primary target. Rust has a rich and varied package system, about the only assumption most packages make is that you’re using the Rust standard library. By comparison lot of Swift packages (which is a much smaller ecosystem anyway that’s slowly transitioning away from Cocapods, Carthage etc) will lean on OS APIs that won’t work if you compile for Linux or WASM[1].

I want Swift to be a more convenient Rust but it just isn’t there. e.g look at IBM abandoning Swift on the server not that long ago.

[1] for example, this blog post:

https://swiftrocks.com/weak-dictionary-values-in-swift

Discusses making a dictionary with weak values in Swift. It has a homegrown Swift version then discusses using NSMapTable… which isn’t available on Linux. But you wouldn’t know that reading the article because the assumption is that you’re running on an Apple platform.

Re:Swift is a more convenient Rust by 369548684892826 on Friday September 06, 2024 @07:32AM (#41465148)
Swift is in its .NET Framework stage. I’m looking forward to Swift Core!
Re:Swift is a more convenient Rust by lolinder on Friday September 06, 2024 @08:11AM (#41465426)
The difference is that Microsoft very intentionally decided it was going to make .NET cross-platform as a strategic play. Apple has recently shown a willingness to get out of the way of cross-platform Swift, but I haven't yet seen evidence that they're throwing any significant weight behind it. They have an even worse track record than Microsoft did of investing heavily in locking developers into their ecosystem, so I'll have to see quite a bit of evidence to believe they're actually serious about cross-platform Swift.
Re:Swift is a more convenient Rust by afavour on Friday September 06, 2024 @07:55AM (#41465321)
I like that comparison! But it might require Apple’s perspective as a company to shift in the same way Microsoft’s did. We’ll see, I guess…
Re:Swift is a more convenient Rust by pzo on Friday September 06, 2024 @08:18AM (#41465484)
It might be too late. IMHO Microsoft also did transition too late and these days .NET is less relevant today than it used to be - even many microsoft apps are build using React Native or Electron.
Re:Swift is a more convenient Rust by nicce on Friday September 06, 2024 @08:34AM (#41465569)
> even many microsoft apps are build using React Native or Electron.

I doubt that .NET has much to do with it. There are just many more JavaScript developers who know how to make UIs.

Re:Swift is a more convenient Rust by consteval on Friday September 06, 2024 @01:08PM (#41467887)
That's because the web is cross platform, truly. It's not a separate issue - the prevalence of the web is exactly due to platforms like .NET being limited. If .NET (and others) were cross platform much earlier, I think many applications would be true apps instead of web apps right now.
Re:Swift is a more convenient Rust by pjmlp on Saturday September 07, 2024 @05:19AM (#41472680)
As someone mostly focused on Java and .NET ecosystems, for the last 20 years, the problem isn't the transition, rather the team is hindered by upper management goals.

While they do their best to open source .NET and related SDK tooling, the whole IDE story has been a bit of a mess, rewriting VS4Mac only to kill it shortly after the rewrite reached 1.0, C# DevKit under the same license as VS, the stuff that will never leave Windows or VS to Mac/Linux, Xamarin.Forms rewrite, while not taking GNU/Linux into consideration, and using Catalyst for macOS MAUI backend, dotnet watch drama, some of the ASP.NET features seen as way to sell Azure stuff,....

If you look closer, you will notice that usually the React Native or Electron based applications are from business units that are mostly C++ focused, that never had great love for .NET in first place.

While the team tries to cater to new generations with making .NET development a great experience, even with some constraints in cross-platform deployments, I think they would gain more by fixing the bad perception .NET still gets in UNIX shops, which those upper management decisions don't make any better, regardless of how great .NET happens to be.

Re:Swift is a more convenient Rust by lukeh on Friday September 06, 2024 @07:43AM (#41465235)
Well, that article also presents a pure Swift (non-Foundation) solution, WeakRef.
Re:Swift is a more convenient Rust by afavour on Friday September 06, 2024 @07:51AM (#41465294)
Yes, I mentioned that. There’s probably a better example but this is off the top of my head as something I experienced myself. My point is that the blog post suggests the Swift native version then discusses NSMapTable without ever calling out the fact that you can’t use the latter cross-platform. I find that endemic in the Swift community, there’s a base assumption you’re coding on an Apple platform (and often specifically on iOS!), it adds an additional barrier to getting things done.
Re:Swift is a more convenient Rust by naman34 on Saturday September 07, 2024 @08:56PM (#41477448)
And that article is from 2020. A lot has changed since.
Re:Swift is a more convenient Rust by naman34 on Saturday September 07, 2024 @08:49PM (#41477429)
I added a new section to the post with links and information to dispel this myth that Swift is only for Apple platforms.
Re:Swift is a more convenient Rust by jnrk on Monday September 09, 2024 @12:43PM (#41490369)
> look at IBM abandoning Swift on the server not that long ago

That was back in 2019..