Peak Objective-C
Since Swift’s introduction at last year’s WWDC, iOS and OS X developers have debated over the answer to a common question for platform newcomers: “Which language should I learn, Objective-C or Swift?” Until recently, there was no definitive answer.
The nuanced truth was that both choices offered benefits and drawbacks. Objective-C was and remains fast, stable, has great IDE support and years of community Q&A available online, all of which can make picking up the language relatively easy for newcomers if they already have experience in C and/or other object-oriented languages.
Swift, being new and unworldly, had none of these advantages. It would almost certainly (and did) undergo fairly major changes – Apple even explicitly stated that they wouldn’t maintain syntax compatibility between language revisions, meaning extra work would need to be (and has been) done by early adopters to stay current with the language changes. Most of the high-level iOS and OS X frameworks are written in Objective-C, and using them in Swift through the language bridge was awkward at best. Worse was that Xcode didn’t even support Swift very well: compiler crashes and undecipherable error messages were very common.
On the other hand, Swift was and is clearly the future, so learning it early can put a developer ahead and help them stand out. The language itself truly can eliminate entire classes of common programming errors, and its consistent and modern design provides significantly better developer ergonomics than a 30-plus year old superset of C. (I’ve been writing Objective-C since college and I still need to look up the correct block definition syntax, every time.)
I believe the answer to the “Swift-or-Objective-C” question changes this month, with the release of Swift 2.0. The Swift development team — in fact, all of Apple’s software engineering teams — have moved tremendously fast to give the next iteration of the Swift greatly improved language, framework, and IDE support. Combined with a rapid adoption by the community, Swift has a nearly tangible feeling of momentum. It’s now mature enough to have tackled most of the drawbacks listed above, and so the answer is now a resounding “Swift”.
There’s an important corollary to the above: Because of Swift’s great progress, almost no one coming into the iOS or OS X development world will choose to learn Objective-C – first or perhaps ever. That is to say, we’ve reached Peak Objective-C.
Existing Objective-C usage outside the Apple ecosystem is obscure at best, and with Swift taking it’s place, the only reason to know it is to work on existing Objective-C code bases. With no new developers choosing to learn it except by necessity, the language will begin it’s slow descent into “legacy” status. In fact, there’s good reason to believe this has already started: The TIOBE index shows a fairly precipitous drop after Swift’s introduction in June 2014, from which one might conclude that “Peak Objective-C” may have happened last year. Indeed, Objective-C is scheduled to fall out of the TIOBE’s top 20 index before the end of the year, and other sources show similar trends.1
Of course, Objective-C isn’t going away in the near future. Apple and the Swift team have made this clear in their communication with developers. But Swift offers material benefits over Objective-C and — now — little to no reason to avoid. There’s no telling when Apple will introduce the first Swift-native (and Swift-only) framework, perhaps one that eschews the object-oriented nature of Cocoa in favor of one more protocol-oriented.2 Although this probably won’t happen until at least June 2016, it’s worth thinking about now. To be unable to use such a new framework would be a serious competitive disadvantage.
Luckily, Apple has made it easy for developers to adopt and integrate Swift into existing projects: Objective-C generics and nullability specifiers go a long way in improving compatibility between the languages. Perhaps ironically, Objective-C is being improved by Swift, but developers still need to choose to use it.
Existing OS X and iOS developers and project managers need take note of this major change. The longer they put off adopting Swift, the harder it will be for them find and hire or collaborate with other developers who have learned, are still writing, and still want to write Objective-C projects. While this shift won’t happen overnight, I think we will be surprised with how quickly we find ourselves looking back at Objective-C with (perhaps more than) a tinge of distaste.
-
I don’t mean to imply that TIOBE be considered the authority on programming language popularity, but it seems fairly accurate. Github and StackOverflow watcher RedMonk puts Objective-C at the 10th most popular language, though Swift is already in 18th place. (Objective-C peaked at #9 last year.) StackOverflow’s own developer survey shows Swift as the “Most Loved” language of 2015, and shows Objective-C dropping from 11.9% popularity in 2014 to 7.8% in 2015 – this loss is mostly attributed to AngularJS and Node.js however, as Swift does not yet rank in the most popular there. ↩
-
See the Protocol Oriented Programming in Swift talk from WWDC 2015. ↩