3 ms·
Why do I then see NSGarbage all over the place in Swift code? Swift is a language facade over Objective C.
by zamalek 6y ago
Why do I then see NSGarbage all over the place in Swift code? Swift is a language facade over Objective C.
- saagarjha 6y agoBecause Swift allows interoperatability with Objective-C frameworks, such as the ones that ship with Apple's platforms. It's easy to see that Swift is not a language façade over Objective-C because you can write a type that cannot be represented in Objective-C almost trivially.
- zamalek 6y agoBut you still have to use the awful ObjectiveC idioms. That's the problem. I did not refer to the limited Swift wrappers, I in-fact explicitly excluded it.
- saagarjha 6y agoYou have to use Objective-C idioms because Apple wrote that code in Objective-C, not Swift. If your complaint is "why can't Swift take my Objective-C code and not only provide a fairly decent interface to it, completely change the API so that it fits perfectly into Swift regardless of issues like ownership and interface design" that's just an impossible bar to set for it.
- zamalek 6y agoRust has done that, with multiple platforms. .Net has done that, with multiple platforms. Dart has done that, with multiple platforms. Apple doesn't care for anything except iOS. That is why Swift won't be taken seriously on anything except iOS.
- saagarjha 6y agoAs far as I am aware, all of those require someone to explicitly go in and create a wrapper, which is worse than what Swift gives you out of the box. So how are they better?
- zamalek 6y agoBecause they all have 1st-party wrappers.
- saagarjha 6y agoSwift is adding their own as you can see, they’ve been using Foundation until now because it’s really not that bad of an interface. Also, I disagree with the claim that Rust has first-party wrappers, it barely has first-party anything to be honest.
- andrewjl 6y agoIn newer versions of Swift the need for almost all prefixing has been removed. You can still say it's a facade when using things like UIKit, but as we've seen in the past few years w/ SwiftUI that is changing. It's already no longer the case if you're doing anything related to heavy duty computation [Accelerate, Metal & others have Swift-specific APIs now] or networking [SwiftNIO].