Tuesday, May 24, 2016

Swift and Objective-C

There have been a ton of discussions and think pieces written on this topic, but I wanted to get my thoughts out there in a longer form than 140 character blurbs.

Think pieces? Yes, think pieces. Almost every argument for dynamism or keeping Objective-C’s better parts are making one of the following assumptions:
  • Apple has no interest in dynamism in Swift.
  • Apple has no concept of what Objective-C can do and why it’s beneficial.
  • The Swift Core Team isn’t made up of some of the smartest people out there.
  • There are no plans to create a Swift-based version of the frameworks.
  • Objective-C is being phased out.
  • Swift only exists to make iOS/Mac apps.
And so on. Thing is, this is Apple. They kept Swift secret for years before they told us about it. There’s a longer-term plan at work, I’m certain of it.

Is Objective-C dead? Hardly. Is Swift complete? Again, hardly. Can they coexist? Certainly (though sometimes with a bit of pain). Is Objective-C going away? Doubt it. In fact, it would be utterly naive to think so. Dynamic features in Swift are coming, it’s been mentioned by People in the Know™. Native frameworks are coming, just not immediately (a stable API and a stable ABI are higher priority).

Last, but certainly not least, is that Swift is a cross-platform language. What’s good for the language isn’t necessarily what’s good for UIKIt or AppKit. This is a tightrope the Core Team must walk, figuring out how to manage the language, the open-source process, Apple’s plans, future-proofing, and tons of other factors. They are incredibly smart, but they are limited in number. This all can’t happen overnight and I’d argue strongly that it shouldn’t. For the next major release (or two), I’d expect a focus on stability.

Either way, I doubt your complaints aren’t being heard. There’s a lot of noise and there are people traversing the chaos. Relax. It’s coming. This is only possible because Objective-C is so stable and provides a solid foundation (pun intended). Your toolbox isn’t limiting you–it’s stronger than it has ever been.

Update: Chris Lattner on dynamic dispatch

Update: Wil Shipley on this whole thing