Objective-C vs Swift: iOS Comparison [2023 Update]

Photo of Aleksander Popko

Aleksander Popko

Jan 24, 2023 • 14 min read
kaboompics.com_iPhone_6_on_the_desk-455569-edited

Taking into consideration Objective-c and Swift, which one is the best language for iOS app development?

We explore the differences below, including performance and features, plus when to choose one over the other.

Any iOS app development project starts with a key decision: choosing the right programming language. When it comes to native iOS app development, there are two possibilities: Objective-C and Swift. What are the differences between Objective-C and Swift, the pros and cons of each, and which one is the best choice for your project? Let’s find out.

What is Objective-C?

Objective-C is a well-established programming language that was created by Stepstone company in the early 1980s. It was released to the public in 1988, when Brad Cox and Tom Love published a book called “Object-Oriented Programming: An Evolutionary Approach”. In the late 1980s, Objective-C was licensed by NeXT Computer, Inc. to develop their NeXTStep frameworks. NeXT was acquired by Apple in 1997, which is how Objective-C became the standard language for iOS app development for years to come.

Objective-C features

Objective-C brings together features from two programming languages: C and Smalltalk. As a result, it has a complicated, verbose syntax. The object syntax is derived from Smalltalk, while the syntax for non-object-oriented operations is the same as C.

Objective-C uses dynamic typing and message passing, and its classes are divided into two code blocks: the interface and the implementation, which live in separate files. Objective-C is a powerful language, but its heritage makes it feel antiquated and cumbersome compared to Swift.

What is Swift?

Swift is a relatively new programming language that was created by Apple employee Chris Lattner in 2010 and introduced to the public in 2014. It’s an advancement of Objective-C, designed to make writing and maintaining code easier.

The general-purpose programming language offers an effective way to write software for desktops, mobile phones, and servers. It suits performance-sensitive coding and provides quick bug recognition and fixing.

Swift utilizes simple and concise coding, with fewer lines needed for the same operation than Objective-C. It boasts convenient maintenance, requiring just a single code file. Furthermore, Swift supports the integration of dynamic libraries.

Alongside Apple platforms, Swift is also compatible with Linux. Overall, it’s a rapidly growing programming language with a great potential.

Swift features

Because of its modern syntax and improved safety features like type inference, Swift simplifies the iOS app development process. It also offers many of the qualities today’s developers expect from a programming language: generics, optionals, type inference, and higher-order functions.

In September 2022, Swift 5.7 was released, introducing “major additions to the language and standard library, alongside enhancements to the Swift compiler for a better developer experience, improvements to tools in the Swift ecosystem, such as SourceKit-LSP and the Swift Package Manager, plus refined Windows support”.

Swift vs Objective-C: performance

The features of a programming language have a huge impact on the business aspects of iOS app development, primarily around speed. When comparing Swift vs Objective-C, app development with Swift is faster.

Why? Swift’s use of generics and higher-order functions result in cleaner, more reusable code, while optionals and type inference transfer responsibility for code safety from the programmer to the compiler. Additionally, since Swift offers a more concise syntax and there’s no need to create two code blocks for the interface and implementation of an object, programmers can write fewer lines of code with the same result.

Combined, these factors make app development faster with Swift. Speaking from my and my iOS developer colleagues’ experience, I can confirm that it’s not just a theory, but an observable fact. There are comparisons for the speed of the applications themselves, with Apple claiming that apps written with Swift are up to 2.6 times faster than Objective-C!

Objective-C advantages

  • It’s existed for over three decades and is well-tested. Indeed, there are millions of lines of code written in Objective-C, as well as many well-documented, third-party frameworks. Moreover, there’s an answer for nearly every Objective-C-related question: Stack Overflow shows over 321,899 Swift questions, and 292,632 of them are marked with the Objective-C tag.
  • Good compatibility with C and C++. Because Objective-C is a superset of C, it works relatively smoothly with C and C++ code.
  • The Objective-C language is stable. If you develop an application using Objective-C, it's unlikely you'll need to spend money on migrating the app to a new language version after a few months.

Objective-C disadvantages

  • Its age can also be a disadvantage. Since Objective-C has been somewhat superseded by Swift, many of its libraries and tools aren’t maintained anymore.
  • Objective-C is harder to learn. It differs significantly from modern programming languages. For example, aspects like memory management are harder to grasp than with Swift. That makes it easier for beginners and Objective-C developers to learn Swift, as opposed to the other way around.
  • The number of developers who know how to use it is decreasing. Because Objective-C is harder to learn and use, most new iOS developers start their careers by exclusively learning Swift. On the other hand, experienced developers who are acquainted with Objective-C are usually familiar with Swift, or at least ready to learn it.
  • An app developed in Objective-C may be easier to hack than its Swift alternative. Objective-C is well-known and has existed for decades, meaning reverse engineering tools are also well-developed.

Advantages of Apple’s Swift programming language

    • Swift is safer. Because of its features (like generics, optionals, and type inference), apps developed in Swift are less prone to bugs and crashes than apps developed using Objective-C.
    • Apple is focused on Swift’s development. Apple constantly develops this language, adding new features regularly, while actively supporting the developers that use it. At every WWDC (Apple’s annual Worldwide Developers Conference), there are technical talks about Swift, and there’s a thriving developer community built around the programming language. There are even frameworks enabling developers to use Swift as a backend language.
    • It has the SwiftUI framework for building interfaces. SwiftUI was introduced by Apple in 2019 – a framework enabling developers to build captivating user interfaces with ease and speed, unmatched by UIKit (the only UI framework available to Objective-C). While it’s still on the road to being the main tool for UI building in iOS, it has many strong points and can be used interchangeably with UIKit. If you need a small demo app just to see how your idea would look, SwiftUI is a match made in heaven.
    • Developers simply prefer using Swift. According to the 2022 Stack Overflow Developer Survey, 63% of iOS Developers love using Swift, while over 76% dread Objective-C. Needless to say, a motivated developer works better than the one filled with dread!
    • Swift Package Manager. This is a tool for easy management of dependencies, third-party libraries, resources, etc. It’s relatively young (released in September 2016) and has replaced tools like CocoaPods and Carthage, which were previously the default choices of developers.

Disadvantages of the Swift programming language

    • It’s still relatively new. While stable and safe to use, frequent Swift updates can introduce features that aren’t compatible with older versions of iOS. That can be a driving force for updating your apps to a newer version of iOS, but it may also mean you drop support for old devices (usually older than six years).
    • Cross-platform support is incomplete. While Swift supports all Apple platforms, Linux, and Windows (since 2020), cross-platform apps are best left to React Native, Xamarin, and Flutter. There’s a potential to use Swift with Kotlin Multiplatform Mobile, but it’s still in the early stages of development.

Swift vs Objective-C: Important differences

Below, we compare and contrast Swift vs Objective-C by looking at a range of metrics, including typing, mutability, and statement terminators.

Metric

Objective-C

Swift

File structure of a class declaration.

Interface is separated from implementation. The first lives in the header file (Filename.h), while the implementation resides in the “.m” file. It’s possible to have both in the same file, but this is the usual convention.

Interface and implementation aren’t separated – they’re both in the same file.

Typing

A mix of static and dynamic typing, with most things (like types, or dispatching) being dynamic.

Statically typed (types are checked at compile time).

Mutability

Properties are all variables (you can mark them as constants, but in reality, few people do this).

By default, all objects are mutable.

Mutability in base classes like String is controlled by the class name you use – i.e. NSString is always immutable, while NSMutableString is always mutable.

Mutability is controlled by using var or let.

Booleans

You can use true or false, YES or NO, and write the type in uppercase BOOL or lowercase bool. Follow whatever coding convention you find in the project, which is usually a combination of BOOL, YES, and NO.

Type is declared in title case Bool and values are in lowercase true and false.

Statement terminator

A semicolon (;)

You must put the terminator at the end of each statement (usually at the end of each line).

No such thing is needed with Swift.

When to choose Swift vs Objective-C

In most cases, Swift is a better choice over Objective-C for building iOS apps. Most – if not virtually all – new iOS apps are built using Swift. Indeed, Swift’s maturity and production readiness are confirmed by the fact it powers apps like LinkedIn, Lyft, Khan Academy, Airbnb, Eventbrite, Sky Guide, Wikipedia, Coursera, Slack, and VSCO.

However, there are at least two scenarios where it’s beneficial to use Objective-C:

  1. If you have a large codebase written in Objective-C and need to maintain it or add just a few new features, it may be better to continue using Objective-C. While Swift is interoperable with Objective-C, meaning you can use both languages in one project, maintaining such an app can cause problems. For example, there may be edge cases where you need a developer who’s proficient in both languages. On top of that, switching between two languages will most likely impact a developer’s productivity.
  2. If you regularly use C or C++ third-party frameworks, Objective-C is worth considering, because Swift needs a separate wrapper to be created, which is often more problematic than going ahead with Objective-C.

If you’re creating an app from scratch and don’t have to think about the above limitations, it’s definitely better to use Swift code because it has all the aforementioned qualities.

Objective-C vs Swift: programming language’s popularity

Is Objective-C still relevant in 2023? According to the 2022 Stack Overflow Developer Survey referenced earlier, in the “Most popular technologies” category, Swift is the preferred language of 4.91% of respondents, while Objective-C is favored by just 2.39%. Meanwhile, for those learning to code, just 0.99% chose Objective-C (versus Swift’s 3.35%).

Research by JetBrains revealed that 76% of developers are skilled in Swift, 13% are proficient in Swift and Objective-C, and just 11% are adept at Objective-C alone.

Looking at the TIOBE Index for January 2023 – an indicator of a programming language's popularity – Swift ranks at number 11, with Objective-C way down at 23. That being said, according to the PYPL PopularitY of Programming Language Index, Swift comes in at number nine, with Objective-C just one place below.

Popularity of programming language 2023

According to Career Karma, as well as Apple, companies such as Eventbrite, Facebook, IBM, LinkedIn, Lyft, and Uber use Swift. At the same time, StackShare references enterprises such as Pinterest, Slack, and Instagram using Objective-C.

iOS Swift vs Objective-C: summary

When it comes to starting a new iOS app development project, the programming language you choose is crucial. It impacts other choices down the line, such as architecture and frameworks. Building apps in Swift is faster, safer, and more enjoyable. However, it’s important to remember that decisions are made in a specific context. Swift is a modern and powerful programming language, but no option is a silver bullet.

Photo of Aleksander Popko

More posts by this author

Aleksander Popko

After graduating Computer Science and Econometrics, Aleksander spent some time working as a...

We're Netguru!

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency
Let's talk business!

Trusted by:

  • Vector-5
  • Babbel logo
  • Merc logo
  • Ikea logo
  • Volkswagen logo
  • UBS_Home