Objective C or Swift ? Which should I learn ? You should learn Swift!

swift

As someone who has developed extensively for the blackberry, windows phone, android and tizen platforms (and is invested in learning a new language or platform every year or so) … iOS is my next destination. Apparently, iOS apps can be written in both Objective C (the older and more used language for programming iOS apps) or Swift (apples new and fairly well received language, released in 2014) – and given that I have a full-time job (where learning new stuff is in the DNA), a practical decision on my hands is whether to invest in learning Objective-C or Swift!  And that’s what this post is all about – how Swift emerged as my top pick! Ofcourse, this article is meant for beginners to iOS application development who are deciding on which of these two language to invest in learning.

An overview of Pros and Cons

The first logical step in making this decision is an attempt to understand the (technical) pro’s and cons of each language. Is it easy to learn (we all have limited time .. remember)? Is it fully functional – i.e. can I use it to successfully implement all of my crazy ideas? What does support and future compatibility look like? What does backward compatibility look like and is this a problem for me?

Cons

To start with, I looked through a lengthy discussion on Quora on the very same topic. Interestingly, many of the contributors recommended that one first learns Objective-C and then Swift ,or Objective-C alone (should time be a limitation). They cited issues such as Objective C being more robust for lower level programming, most existing application code-bases being written in Objective-C and the “in-development” / “flux” / “buggy” status of Swift. Similar sentiments are echoed by other articles which highlight situations in which Swift may not deliver on its promise of being faster, and complications with backward compatibility (see here ). However, it is important to note that many of these drawbacks have been or will be addressed with time (many of the “con” posts were published in 2016).

Pros

As a new language, Swift has a ton of good things going! For me the most appealing are the fact that it is designed to be easy to read and hence learn, it is faster than Objective C and it is being championed by Apple (meaning support will likely grow). Google trend chart below shows interest in Swift is increasing as the language matures.

Screen Shot 2016-06-01 at 3.08.41 PM

Other important pro’s (as seen on the Swift website) include it being :

Multiple iOS devices compliant : Swift is a powerful and intuitive programming language for iOS, OS X, tvOS, and watchOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast.

Faster and more powerful : This means it is equal to the task in implementing any crazy app idea you may have! Swift is a successor to both the C and Objective-C languages. It includes low-level primitives such as types, flow control, and operators. It also provides object-oriented features such as classes, protocols, and generics giving Cocoa and Cocoa Touch developers the performance and power they demand.

Safer : Swift eliminates entire classes of unsafe code. Variables are always initialized before use, arrays and integers are checked for overflow, and memory is managed automatically. It addresses some important safety and flow control issues discussed here.

Inter-operable with Objective-C : Swift code co-exists along side your existing Objective-C files in the same project, with full access to your Objective-C API, making it easy to adopt. This further increases its capabilities as 3rd party Objective-C libraries can be easily integrated to improve functionality.

Open-source : I bet you didn’t know this! Swift is developed in the open at Swift.org, with source code, a bug tracker, mailing lists, and regular development builds available for everyone.

Conclusions

While I tend to highly favor Swift at this moment, there are still several situations that warrant investment in Objective-C for developing iOS apps. First, if you your job role will heavily involve maintaining existing code base .. you might want to invest in learning Objective-C. Also, if the applications you will be developing will rely heavily on access to low level computation (e.g fine grained thread management, access to GPU for running specific algorithms etc), it may be worthwhile towing the Objective-C route.

In the mean time, get started with Swift application development using the apple developer resources here.

About Vykthur

Mobile and Web App Developer and Researcher. Passionate about learning, teaching, and recently - writing.
This entry was posted in Developer Tips and tagged , , , . Bookmark the permalink.