4 ms·
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.
by airstrike 4mo 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.
- jadengeller 4mo agoModern Swift borrows a lot from Rust! And it also has its own benefits, both ergonomic and also supporting eg generic in dynamic libraries
- airstrike 4mo agoThese 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
- DenisChetwynd 4mo agomaybe so on the surface, but it remains quite massive underneath; these languages are fundamentally different and target entirely different use cases
- airstrike 4mo agoI'm not sure Rust has one specific use case as its main goal, despite being immediately suitable for systems programming. I use it for making user-facing desktop applications, to name one example.
- MBCook 4mo agoIn 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.
- inkyoto 4mo agoI see Swift as a more approachable version of Rust. If somebody is mulling over Rust but finds it too difficult to grasp, they could start off with Swift first and then move over to Rust. One of the main advantages of Rust is a more developed and thriving ecosystem.
- stasomatic 4mo agoIt has an unfortunate name though, maybe a short shelf life. Rust++ doesn’t seem inviting either.
- steveklabnik 4mo agoRust does not have a ++ operator, so that name would make no sense.
- stasomatic 4mo agoNot yet.
- kibwen 4mo agoI can assure you that Rust will never have a ++ operator. Not only is it semantically bizarre, it's entirely unnecessary in a language where iteration is overwhelmingly performed via iterators rather than via manually incrementing array indices.
- stasomatic 4mo agoIs that a bullet point in the Rust manifesto? :) In any case, ++ has taken another meaning outside of operator loading and such some. The “Rust” branding, to this rando, implies corrosion, oxidation, decay, regardless of the true origin of the name. Swift is “quick”, Java is “caffeine”, Rust is something I need kerosene for.
- 4mo ago
- geodel 4mo agoApple is not going bet all on language whose roadmap they do not control 100%.
- vardump 4mo agoDoes it borrow borrow checker?
- deleted 4mo ago[deleted]
- anextio 4mo agoYes, it has a borrow checker.
- tialaramex 4mo agoI 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.
- MBCook 4mo agoThey 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.
- airspeedswift 4mo agoYou 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.
- pjmlp 4mo agoYou can pick and chose, and memory ownership is getting better in latest versions. Being more ergonomic is relevant enough for increasing language adoption, that possible improvements are now on Rust roadmap.
- ecshafer 4mo agoSwift and Rust were developed at similar times. I think of them more as having similar influences than borrowing from each other.
- est31 4mo agoSimilar times and the Rust originator went on to work on Swift after it.
- DenisChetwynd 4mo agoGraydon Hoare's impact on the language is marginal than that of Chris Lattner, the originator (also, Hoare joined the team much later)
- pohl 4mo agoThere’s no reason to invent your own head canon, the influence was openly acknowledged when Swift was new and it continues now that the language is developed out in the open (see Swift Ownership Manifesto)
- zarzavat 4mo agoObviously Rust was first but over time both languages have been taking inspiration from each other. For example let-else was motivated directly because of its success in Swift: https://rust-lang.github.io/rfcs/3137-let-else.html#prior-art https://rust-lang.github.io/rfcs/3137-let-else.html#prior-ar...
- pjmlp 4mo agoAdditionally both have influences from CLU, C++, Object Pascal, Modula-2, Mesa/Cedar, Standard ML, Cyclone. Many features that get discussed as being Swift/Rust, trace back to one of those languages.
- AceJohnny2 4mo agoRust doesn't have an ABI [1]. Swift needed one to be a useable application language: https://faultlore.com/blah/swift-abi/ 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
- afavour 4mo agoOne 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.
- inkyoto 4mo agoNot just interoperability with Objective C but with C (full) and C++ (increasingly better but not full) as well. Swift is also interoperable with different versions of itself courtesy of the Swift stable ABI (Application Binary Interface)[0], which they invested a significant amount of time into at the expense of adding other new features to the language, which have come along later. Rust offers a different approach: recompile everything and static linking. [0] https://faultlore.com/blah/swift-abi/ https://faultlore.com/blah/swift-abi/
- pjmlp 4mo agoC compatibility comes via Objective-C, because contrary to C++, Objective-C extends C, instead of being based on a C subset. You missed Java as well.
- pjmlp 4mo agoSwift takes the right approach in language ergonomics, many of its use cases would be much harder with explicit .clone() all over the place, lack of back references, no standard ABI for binary libraries, interop with Objective-C and C++, no standard concurrency runtime, or error handling types. Rust 2026 roadmap has language ergonomics on it for a reason. That said, outside Apple ecosystem you probably better with Rust, or if one has no GC issues, OCaml, Haskell, F#, Scala, C#.
- jounker 4mo agoApple has a runtime system that looks a lot like smalltalk. Everything at that layer is dynamic. They needed a language that could seamlessly interact with that system.