Objective-C vs Swift.
This is like the battle of old vs new, youth vs experience, father against son. All the cool kids seem to like Swift and hype around it is huge. Although elder and more experienced guys like Crusty seems to be loyal to Objective-C. So who is right? And what’s more important what should you do about it?
I decided to compile all available information in one article, so whether you are an experienced developer or totally new in iOS development you will be able to decide. At least, the more you know the better.
Objective-C 2.0 was introduced WWDC 2006 but it seems like it was around for decades. Original Objective-C first appeared in 1984 so its 32 years old! Objective-C is an open-sourced language mostly used on Apple platforms (macOS, iOS, etc.).
As for salaries, I wasn’t able to find anything fresh except this chart from qz.com. But this is really outdated.
Swift was introduced in WWDC 2014 and by the time of writing this article, there is already a 3rd version of this programming language. It is open-sourced language mostly used on Apple platforms. Actively propagated by IBM. According to redmonk.com, it is now the 17th most popular programming language and fastest growing language in history. All new code samples are written in Swift, most of bloggers using it.
So probably you might think right now: “Why do I wasting my time reading this article — I should definitely being learning Swift!”. I couldn’t agree more. You should learn it. But should you use it in your next project? Should you ignore Objective-C as new iOS developer? Let’s take a closer look.
I will try to focus on pros and cons of using Objective-C and learning it.
- Objective-C is a mature language with a huge community, lots of experienced developers, best practices, and coding styles.
- There are plenty of third-party libs, that are well tested, used in many huge projects. (note: some of then may not be updated to the latest iOS releases)
- There are tons of legacy code that needs to be supported. (This one especially for Crusty)
- Compatibility with other languages. You can use C or C++ with no problem inside your Objective-C files. If you need to use C++ in your Swift code you should first wrap it in Objective-C code first and then import that in Swift.
- Sooner or later Objective-C won’t be able to support some new features, so there will be Swift-only marked methods and frameworks.
- It is an outdated language with lack of many valuable features available in other programming languages.(Just look at Swift enums and cry)
So basically, if you already have lots of experience in Objective-C and you know some C/C++ you will be doing just fine for the next 5 years or at least until Apple will be a major company. There always be a niche for you.
pros of using Swift are the following:
- Modern, more expressive, feature-rich programming language.
- Very active community.
- Ported to other platforms
- Rapidly applying new features and proposals (which is not nesses early a good thing if you are making an app for the market. Even between Xcode 8 betas, there were painful changes that require you to rewrite a lot of code. And don’t belive them saying you have a migration tool!)
- lack of 3-d party solutions due to fast evolution of language. There are lots of projects on Github that still on Swift 1.2.
- Immature community and a lot of misleading advice
I won’t mention here that XCode still has issues with Swift (and generally it has issues. You can read some hilarious examples here)
Play it safe — learn them both. If you are a new developer you should still strongly consider to start with Objective-C. There are still more jobs for Objective-C developers than for Swift ones. And most of Swift positions are actually Swift/Objective-C.
If you are an expirienced developer you should be learning Swift. Probably you don’t need to start your next project in Swift until Swift 4 which will introduce source and ABI stability. But you may write some parts of your app in Swift already. It will increase the size of your app and will be a pain in the ass, but after all, it will worth it.
So, if you have any questions reach me on Twitter Andrei Malyhin