Starting an iOS project involves making a key decision: choosing the language for the development. When it comes to native mobile app development, there are two possibilities: Objective-C and Swift. What are the differences between them? What are pros and cons of each one? And, finally, which language will be better for your project?
Objective-C is a long-standing programming language that was created by the Stepstone company in the early 1980s. It was released to the public in 1988, when Brad Cox and Tom Love published a book, “Object-Oriented Programming: An Evolutionary Approach”. In the late 1980s, Objective-C was licensed by NeXT Computer, Inc. to develop the NeXTStep frameworks and was eventually acquired by Apple. This is how it became the standard for many years in the area of iOS apps development.
Objective-C was created under the influence of two other programming languages: C and Smalltalk. This is why it has such a complicated, verbose syntax. It derives its object syntax from Smalltalk, while syntax for non-object-oriented operations is the same as in C. Objective-C uses dynamic typing and message passing. It also requires dividing classes into two code blocks: interface and implementation.
Swift is a relatively new programming language. Apple started working on Swift in 2010 and released it to the public in 2014. In 2015, Swift became open source. It abandons the Smalltalk and C heritage and has all the features that modern programming languages have: generics, optionals, type inference, and higher-order functions.
The features of a language can sound technical, but they have a huge impact on business aspects, primarily on the speed of development. App development in Swift is faster than in Objective-C. The usage of generics and higher-order functions results in cleaner, more reusable code. Optionals and type inference resulted in the responsibility for the code safety being transferred from the programmer to the compilator. More concise syntax and no need to create two code blocks for a class interface and implementation let programmers write fewer lines of code with the same effect as in Objective-C.
All of this makes development faster. It’s not just a theory – and while there is no official research, I can confirm this fact from my own experience and that of my iOS developer colleagues’ empirical experience.
Development in Swift is faster, but it is not the only factor you should consider when making crucial business decisions. What are the other pros and cons of these two languages?
Pros of Objective-C :
Cons of Objective-C
Pros of Swift
Cons of Swift:
Kamilah Taylor and Kyle Sherman gave an impressive talk about using Swift in LinkedIn. Their conclusions were that Swift is great for small, brand new apps, however, it may not be the best solution for large projects with huge, already existing Objective-C codebases. This talk took place about two years ago. Today, Swift is more mature, and it has outgrown many of its earlier growing pains.
In most cases, developing an application in Swift is a better choice. However, I can think of two cases where you should choose Objective-C:
When it comes to starting a new iOS project, the decision about which programming language to use is crucial. It will impact other choices, such as the architecture or used frameworks. Development in Swift is faster, safer, and more enjoyable from a developer’s perspective. On the other hand, decisions are always made in a specific context. Swift is great, but it is not a silver bullet. There are still some cases where Objective-C may be the right choice.