Swift has had a meteoric rise in popularity since its inception in 2014. In 2015, Swift was rated the most loved programming language on Stack Overflow, and it’s currently ranked 17 in the programming language rankings guide of June 2016, according to Redmonk who wrote “there is no debate that Swift is growing faster than anything else we track.”
That said, according to Redmonk, Objective-C is still ranked higher than Swift. A common question for a new iOS developer is — should I be learning Swift or Objective-C? There have been mixed messages from the iOS developer community.
Many developers embraced Swift from its inception in June 2014. Popular tutorial site Ray Wenderlich fully transitioned all new and previous tutorials to Swift. Other developers such as Natasha the Robot blogged about their experiences exploring this new syntax.
In the early adoption of Swift I was anti-Swift…but the more I started to use it, the more I was forced to use it, the more I liked it… it feels like I’ve got coodies all over me whenever I have to write in Objective-C! Every project that I start now is a Swift project, and it feels natural. Granted, I’m forty years old, I didn’t want to learn something new. I was using Objective-C, and having a good old time with it. Who wants to learn another language? But I’m all for Swift now, and I feel bad I dogged it from the beginning.
It can be instinctive to resist change. Change can be scary — you can feel as though you’re abandoning your built up knowledge and reputation and entering the unknown. I’ve experienced this resistance myself over my career as one skill or tool becomes passe or redundant and others gain favor in the industry. Once you apply yourself to explore new technologies, you can find yourself discovering, once again, the excitement of learning something new. My hope is that you’ll also rekindle that passion as you go through this book.
It’s clear that Swift is constantly evolving and will continue to evolve. On one hand this can be frustrating for maintaining existing codebases, but, on the other hand, changes are, by definition, necessary if we want the language to constantly improve. Objective-C has been around for over 30 years and apart from a revision of the language in 2006, and some recent revisions to keep pace with Swift updates it hasn’t changed much. Not moving with the times resulted in Objective-C commonly receiving criticism that it isn’t a modern language, and ultimately created the conditions that spawned Swift.
Learning iOS development with Swift doesn’t prevent you from also learning Objective-C at some point in the future. Regardless of the language you’re programming in, the underlying frameworks are mostly identical, with tweaks to syntax. Learning iOS development with Swift isn’t necessarily setting your flag firmly in the Swift camp. You can use Objective C code in your Swift project, or vice versa. Learning Swift is a good place to start, and you’ll find exploring Objective-C easier with iOS experience behind you. For comparison, the following demonstrates the same code in Swift and Objective-C.
Swift isn’t necessarily limited to iOS app development. Apple stunned us all in 2015 when they announced that Swift was going open source. IBM embraced the new language, making Swift available to enterprise app developers on IBM Cloud. At InterConnect 2016, Tom Rosamilia, Senior Vice President of IBM Systems commented, “This Swift thing is huge.” Craig Federighi, Senior VP of Software Engineering, said in a podcast interview on Daring Fireball that he hopes for Swift to be “the language, the major language for the next 20 years of programming in our industry.”
It’s clear that Swift’s the future for iOS development. If your plans in iOS development involve maintenance of a codebase, you may need to know Objective-C, but, in general, Swift’s the way forward. The general consensus these days among iOS professionals is, if they were learning iOS now, they’d be doing it in Swift.