Objective C vs. Swift – What’s the Difference?
Ever thought that coding could be done in any other language other than Objective C in Xcode? Yes, it became possible when Apple’s WWDC 2014 came into existence on 2, June.
The first update was the introduction of OS X Yosemite and iOS 8. With over 4000 APIs, it was something remarkable. Along with the package, a new Programming Language named ‘Swift’ arrived, which was entirely new to the developers. With completely new syntax and features, it was a delightful update from Apple.
It was not an easy task to start coding with Swift. WWDC 14 Training Video Sessions are useful in understanding Swift. As per official update from Apple, Swift is a new Programming Language, which is way faster, and performs better, compared to Objective C. They even provided an example with a comparative study on Complex Object Sort with Swift, Objective C and Python.
Objective C vs. Swift
Observing our favorite Objective C and fresher’s favorite Swift, we might not be able to find a big difference. Objective C, which has been in the field since the very beginning of iOS, holds much importance and is quite popular. Simpler Syntax and easy to understand features makes it user-friendly. It is valuable and good but it still lacks some of the features that developers always wanted, just like the Tuple feature introduced in Swift. As per my experience working on both the technologies, it is one of the best feature in Swift. Removal of ’NS’ from Arrays, Dictionaries makes Swift provide comprehendible codes and give a much neater look, providing much more readability. Transition from Objective C to Swift
To make the transition from Objective C to Swift a smooth process, Apple made the syntax similar and more familiar. It removed some of the prefixes and added some suffixes to the existing ones. Features like providing the range for iterative statements, switch functionality revamp, type inference, closures, which are similar to blocks, generics, which can take up any data type, are some of the beneficial ones in Swift. And on the applications side, the change that Swift has brought in is the 1 or 2 lines of code in Swift compared to lengthier code in Objective C. Swift supports Unicode characters, as variable names, which Objective C does not.
Apple considers Swift as a safe, modern and powerful coding language. Playground feature, which is present in Swift, allows the user to interact with a running application, side by side, which Objective C cannot. Swift, being a bit high on the graph, claims to provide a better performance.
So, Should you start learning Objective C or Swift?
Almost all current applications are still in Objective C. It will take some years for Swift to gain its place and importance in iOS applications. Yes, it’s true that some of the applications are getting converted to Swift, but it would take some time to gain prominence.
While exploring iOS, it is recommended to have good knowledge about Objective C and at the same time, sufficient conceptual knowledge about Swift, too. The ideas are same in both Programming Languages. If you are in the midst of Objective C learning, I would recommend not to start with Swift right away. Gather some good knowledge about Objective C, Then, slowly, get to know about Swift. Learn it and work out on some small projects.
The future of Objective C is unpredictable. But according to the updates from Apple, there is a chance that the same will become significantly popular in 5 years from now. By then Swift might leave an indelible mark in the sphere of iOS applications.
Sr. Software Engineer (iOS Development), RapidValue Solutions