Remix.run Logo
airstrike 2 hours ago

As much as I enjoyed Swift, one can only wonder what the world would look like if they had gone with Rust as their default language instead.

afavour 43 minutes ago | parent | next [-]

One of the genius things about Swift is its interop with Objective C. Made the switch over considerably easier for developers. I’m not sure what that looks like in a Rust world.

Rust is also just a more complex language. I’m not convinced the benefits would have been worth it.

AceJohnny2 an hour ago | parent | prev | next [-]

Rust doesn't have an ABI [1]. Swift needed one to be a useable application language:

https://faultlore.com/blah/swift-abi/ (written by a core Rust developer)

[1] apart from the basic/universal C one, which prevents exposing any useful Rust semantics over the interface

jadengeller 2 hours ago | parent | prev [-]

Modern Swift borrows a lot from Rust! And it also has its own benefits, both ergonomic and also supporting eg generic in dynamic libraries

ecshafer 2 hours ago | parent | next [-]

Swift and Rust were developed at similar times. I think of them more as having similar influences than borrowing from each other.

est31 2 hours ago | parent [-]

Similar times and the Rust originator went on to work on Swift after it.

DenisChetwynd 2 hours ago | parent [-]

Graydon Hoare's impact on the language is marginal than that of Chris Lattner, the originator (also, Hoare joined the team much later)

airstrike 2 hours ago | parent | prev | next [-]

These days I mainly write Rust but I did write a semi complex iOS app and enjoyed Swift. I just didn't love how slow the type checker was and how it got lost. I recall having to break things into smaller bits to help the compiler, and there were some oddities about the language.

The gap between the two languages is quite small, it just makes me wish Apple was also all-in on Rust

MBCook 15 minutes ago | parent | next [-]

In the last year they’ve added improvements to the type checker to speed it up, those would have been released now.

They have further and much more significant changes that I think might have recently landed in the development version. That should make an even bigger difference. But it’s not in a released version yet.

And yes, none of us like that one part of Swift. Especially the DRASTIC difference compared to objective-C which really only checked syntax and little else.

It’s still probably my favorite language right now though I don’t get to write in it much.

DenisChetwynd 2 hours ago | parent | prev [-]

maybe so on the surface, but it remains quite massive underneath; these languages are fundamentally different and target entirely different use cases

vardump 2 hours ago | parent | prev [-]

Does it borrow borrow checker?

tialaramex 31 minutes ago | parent | next [-]

I believe Swift tends to use reference counting and copy-on-write strategies. This, like GC, is less for the programmer to think about and doesn't require the semantic checks, but sometimes the performance cost is unacceptable compared to what you'd write in Rust.

airspeedswift 14 minutes ago | parent | next [-]

You can choose to use either refcounting or unique ownership for your types. For most use cases, refcounted (+ copy-on-write) is the best choice and is the default, but the truetype interpreter made extensive use of non-refcounted types to achieve this performance.

MBCook 14 minutes ago | parent | prev [-]

They have either recently added or talked about a borrow style system in the language as a way to avoid more copies and speed things up/lower memory usage/help with asynchronous programming.

2 hours ago | parent | prev | next [-]
[deleted]
anextio an hour ago | parent | prev [-]

Yes, it has a borrow checker.