en flag +1 214 306 68 37

Pros and Cons of Swift Programming Language for iOS App Development

Published:

Apple first introduced Swift as a second official language for macOS, watchOS, tvOS and iOS development in 2014; a year later, the language was made open-source. As of now, 4 official versions of Swift exist: 1.1, 1.2, 2.0, 3.0. Update 19/09/2017 : The latest, 5-th entry (Swift 4.0) was released on 19/09/2017.

Despite quite a young age, Swift has already climbed its way up from the ‘Apple’s experiment’ status to the 11’s place in TIOBE’s listing of the world’s most popular programming languages. Ranking 7 positions higher than its predecessor Objective-C, Swift proves to have completed its initial mission. That is, gaining the trust of the many developers who were used to working with a 30-year-old tried-and-true language and convincing them to invest in something new.

Here we’ll take a look at the advantages that helped Swift become a major programming language for iOS app development, as well as analyze the disadvantages that may still hold it back.

Swift Pros and Cons

Pros of using Swift for iOS development:

Transparency

While the syntax of Objective-C is closer to the notoriously intimidating syntax of C, Swift owes a lot to the syntaxes of much more elegant Ruby, Python and C#. The language is easily readable, since all of its expressions have transparent meanings, and is very simple to learn. In fact, Apple is so confident in the simplicity of Swift, they encourage kids to create apps on it via games on Playgrounds.

But there’s more to Swift’s simplicity than being kid-friendly. The transparency of its code enables scaling up any development project easily: new team members can shortly catch up on existing app code and start contributing to it faster than they would do with an Objective-C app.

Conciseness

One of the aims Swift developers pursued was to make the language less verbose. Thanks to its string interpolation alone, Swift is capable of reducing Objective-C mobile app code by almost 70%. A self-explanatory example is a Lyft app, which lost 2/3 of its initial 75,000 code lines after being rewritten on Swift. Less code always means faster development and testing, cheaper maintenance, as well as fewer resources required for any of these tasks.

Automatic memory management

To achieve best app performance and avoid memory leaks, Swift employs Automatic Reference Counting across all APIs. In other words, it handles memory on its own, enabling the most efficient resource consumption. No manual memory settings are needed, and while making the necessary adjustments developers are guided and supported by Swift’s convenient tools.

Safety

Unlike Objective-C, Swift is a strongly and statically typed language, which allows developers to notice bugs prior to compilation and fix them on the fly. Moreover, Swift has smart nil-pointer safety measures that prevent compiling errors due to null references.

Interoperability with Objective-C

Although this is not an outright advantage over Objective-C, it is definitely a merit on its own. Swift isn’t to completely replace Objective-C, which is and will stay a part of many mobile apps that will need maintenance in the future. The new iOS development language is fully interoperable with its predecessor and can coexist with it in one app, file or code line.

Cons of using Swift for iOS development

Speed

The actual swiftness of iOS Swift development has been a controversial issue since version 1.0, mainly because the initial results weren’t that impressive. But the language has evolved a lot since then, and performance tests results aren’t frustrating anymore. Still, while Apple continues to claim that Swift is 2 times faster than Objective-C, actual tests don’t back up this statement.

When compared to Java in benchmark task performance, Swift does get the upper hand in six tests, shares almost the same result with Java in two tests, and loses to it only in two tests as well. Yet when Objective-C is Swift’s rival, the speed difference between the two is hard to notice.

No backwards compatibility… yet

The language is radically evolving and is somewhat unstable, since currently each new version of Swift does not support the previous one. This means that apps written in Swift 1.0 and 1.2 can’t be maintained in Swift 3.0 and can already be considered history. However, Swift 4.0 seems to be finally turning the situation around and providing support for Swift 3.0. So, soon there’ll be no need to worry about backward compatibility.

End note

Swift has introduced many advantages to iOS development:

  • its conciseness makes mobile apps more lightweight,
  • the simplicity enables fast project upscale,
  • full interoperability with Objective-C enables convenient maintenance or further development of previous projects.

Just like Kotlin for Android development, Swift simply needs time to mature. Hopefully, with a couple of further releases Swift will achieve its declared performance speed and become a completely stable development tool.