Since its introduction in mid-2014, the Swift programming language’s rise to the top of the charts has been practically meteoric. In January 2016, Swift overtook Objective-C for the first time in the TIOBE index, an oft-cited measurement of the popularity of programming languages. One year later, in March 2017, Swift became one of the TIOBE index’s top 10 most popular languages. Freelancing site Upwork, for its part, named Swift as the second-fastest-growing tech skill in the last quarter of 2016.
With a barrage of new tools and technologies constantly being released, developers usually don’t have the time to learn new skills unless the benefits of doing so are obvious (or if their employer makes them). It’s clear that this is the case here—but what exactly are the advantages of Swift that are driving this lightning-quick adoption?
So What Is Swift?
As described by Apple, Swift is a new programming language designed specifically for coding mobile applications on iOS devices. Since December 2015, the language has been an open-source project published under the Apache 2.0 license. Swift is intended to be a full-fledged alternative to, and likely one day a replacement for, the Objective-C programming language. Although they both can be used for other purposes, these days, Swift and Objective-C are mainly used by Apple developers. However, the similarities between the languages end there.
Objective-C is an object-oriented language that’s a superset of its predecessor, the C programming language. With its first release in 1984, Objective-C is more than 30 years old, and it’s definitely showing its age. iOS developers have long complained about the creakiness of Objective-C, causing Apple to continually work on stopgap improvements to the language, like literals and automatic memory management, over the past several years.
With the shortcomings of Objective-C for iOS development so glaring, Apple knew that it would eventually need to redesign iOS programming from the ground up—and that’s where Swift comes in.
The History of Swift Development
Work on Swift at Apple began as early as 2010 under the direction of programmer Chris Lattner. The backstory, however, stretches all the way to 2000, when Lattner was a PhD student at the University of Illinois at Urbana-Champaign. At that time, Lattner was working on a research project known as LLVM, a toolkit for building the front and back ends of compilers out of composable, reusable parts.
Lattner joined Apple after graduation to make LLVM production-ready, where he also began experimenting with a side project that would eventually become the Swift programming language. In building Swift, Lattner and other programmers borrowed concepts from a variety of other languages, from C and Objective-C to more recent innovations like Rust.
Why Native Development in Swift Is Perfect for iOS
When Objective-C was released in 1984, the first Macintosh computer had just been introduced, and iPhones existed only in Steve Jobs’ imagination. Swift, by contrast, has been built from the ground up to be optimized for iOS development. Here’s a look at just a few of Swift’s competitive advantages.
Because Objective-C is beholden to its C roots, it’s not as fast as Apple developers would like it to be. Swift, however, can go toe-to-toe with fast languages like C++. Soon after its initial release in December 2014, Swift 1.2 was already nearing the performance of C++ on the computation-heavy Mandelbrot set algorithm.
When you call a method with an uninitialized pointer in Objective-C, the compiler spits out a no-op. Although the application doesn’t crash as a direct result, it does behave unpredictably, which makes debugging more difficult. On the other hand, Swift is memory-safe, which means that it prevents programmers from directly accessing memory by default and initializes all variables before their use.
Objective-C’s syntax derived from C was confusing, overbearing, and clunky. Developers complained about issues like too many square brackets and having to write lines of bulky, complicated code just to declare a single class. Swift uses modern syntax constructions that make the language less verbose, easier to read, and more pleasant to program in, lowering the barriers to entry for new developers.
Although Objective-C uses the Automatic Reference Counting (ARC) feature, it’s not available for code written in C or APIs such as Core Graphics. This means programmers have to manually manage the program’s memory when working with low-level code, creating the potential for memory leaks. Fortunately, this problem has been solved with Swift: ARC is completely supported for all aspects of a program’s code base.
It’s not an exaggeration to say that Swift is the future of iOS development. In the words of Craig Federighi, Apple’s senior vice president of software engineering, “We think Swift is the next major programming language, the one people are going to be programming in for the coming several decades.”
Sure, this statement may be a little hyperbolic, but it also reveals the commitment that Apple has made to supporting and improving Swift into the foreseeable future. Apple’s commitment and the many technical advantages of Swift over Obj-C is why our team at Dropsource decided early on to focus our efforts on creating an automated programming platform that produced lean, editable and modern Swift source code for your iOS apps.
With the release of Swift 3.0 in 2016 and 4.0 earlier in 2017, and the many continuous improvements, it’s clear that Swift is the reigning champion for programming languages best suited for Apple mobile and wearable devices.