Swift and Objective C

Swift and Objective CSwift has swiftly taken over our lives (Pun intended!). The fact that one does not have to go through the ordeal that is Objective C has got many people rejoicing. So much so, that according to a Stack Overflow survey, “77.6% developers around the globe preferred Swift over Objective C for iOS app development”.

With the introduction of OS X, Apple gave us a lot of new additions, with an all new Swift, the latter aiming to make developers lives easier. With the praise and love Swift is getting from so many quarters, one cannot help but wonder how it can almost overthrow Objective C which has been around since 1983! Well, we are going to talk about the positives of Swift, and some of the ways in which it is touted to be better/easier than Objective C.

Similar to newbies and industry bigshots like C#, C++, Java, Javascript and Python, Swift is very easy to read, and learn as it is similar to the English language, without any of the bulky syntax. It is easier to code as it employs string interpolation without needing any placeholder or token.

A major overhead while developing using Objective C was maintaining two files – one for interface and one for implementation. Though they are practically the same code, the developer is forced to make changes in both files. This is not the case with Swift, as there’s just one file, so easier to start and finish!

Next comes the issue of Pointers. While many C languages inclusive of objective C use Pointers, they are a security overhead, and also troublesome when one is trying to find bugs in the code. But Swift does not allow nil value, so when your code reaches a nil value, it automatically crashes, making it easy for the developer to locate bugs, giving a very clean code.

Finally, there is the case of easier compilation and memory management. Swift is built with the Low Level Virtual Machine (LLVM), a compiler that’s used by languages like Scala, Ruby, Python, C# and Go. The LLVM is faster and smarter than previous C compilers, so more workload is transferred from the programmer to Xcode and the compiler. When  it comes to Memory Management, Swift supports ARC across all APIs, and this stability means less time programmers have to spend focusing on memory management, as “memory leaks” will become obsolete.

Leave a Reply

Your email address will not be published. Required fields are marked *