In June 2014, Apple launched a new programming language named Swift with an aim to create a better programming environment by tools that makes the coding a lot easier for beginners as well as experienced developers. It was introduced as “Objective-C without C” with goal to speed up development of iOS Development by covering the inadequacies of Objective-C.
Before we migrate to Swift for our remaining iOS Development Tutorials there are a few doubts that must be going through every developers mind that need to be sorted out now.
If I’m learning iOS Development now, do i need to learn Objective-C first?
Objective-C is an established language and it’s there since 30 years. Moreover most of the frameworks are written in Objective-C. Majority of apps on the App Store are developed in Objective-C. So, in future if you get a task to migrate the code to Swift for any of those apps, it’s better to be well versed with Objective-C first. Besides, if you’re using a native library that’s in C++ or C and are using a lot of C functions, that’s when knowing Objective-C is a must. Last but not the least the open source communities/forums have been talking in Objective-C all this while. Most of the code snippets available on these open source forums, are written in Objective-C. These reasons are enough to justify why a good look at Objective-C is important. (That’s the reason we’d started our iOS Development tutorials in Objective-C).
Why are developers adapting to Swift when Objective-C is easier to learn?
True. Objective-C being an extension of C is easier to learn and it requires the developer to be more explicit in their code. Other than this Swift has it’s set of advantages over Objective-C. Few of them are listed below.
- Swift isn’t built on C hence it’s syntax is more simpler. We can remove the @ from the numerous strings in Objective-C. There’s no need for semi colons/parentheses in conditional statements
- Swift is type-safe which means the language helps us to be clear about the types of values our code can work with
- With Swift we get Automatic Reference Counting which eases our task by removing the overhead of explicit memory management that had to be specified in Objective-C
- Swift is faster. Libraries handle most of the OSX and iOS user references. According to Apple, development in Swift is 73 percent faster than in Objective-C
- Finally, Swift is made in such a way that it’s compatible with Objective-C. Swift codes can be written inside Objective-C and vice-versa
This brings an end to this tutorial. From the next tutorial, we’ll make a shift towards Swift for the remaining series of our iOS Development Tutorials.