Swift is one of the newest programming languages, having debuted in 2014. In short order, it has become one of the most popular languages on the planet, thanks to Apple’s ecosystem.
Swift Enters the Scene
Prior to 2014, the primary language for macOS and iOS development was Objective-C. Objective-C was released in 1984 by Tom Love and Brad Cox, who were heavily influenced by Smalltalk, the first object-oriented programming language. The C language was, and still is, largely procedural. Love and Cox wanted to integrate Smalltalk-style features with C. The result was the object-oriented Objective-C.
Objective-C gained significant traction in 1988 when Steve Jobs’ second company, NeXT, licensed the programming language for its NeXTSTEP operating system (OS) and the OpenStep application programming interface (API). Years later, when Apple bought NeXT, it used OpenStep as the basis for Mac OS X, which would later become macOS and, in turn, serve as the basis for iOS.
As a result, of Apple’s decision, Objective-C grew its user base even more, as it became the best language for macOS, and later iOS, development. As Apple began to make customized versions of its operating system for its different platforms—iOS, tvOS and watchOS—Apple saw room for improvement and released Swift as a replacement for Objective-C.
With billions of iPhones, iPads and Macs in existence, Swift had a ready-made audience to aid its adoption. According to to the TIOBE Programming Community Index, in 2015 Swift ranked 95 on the list of most popular programming languages. By May of 2019, it ranked 18, moving up to ninth place by the beginning of 2020.
Advantages of Swift
Because Swift is so new, its creators had the advantage of hindsight when making it. By the time work began on it, in 2010, there were a number of languages that had made a splash and introduced new concepts or ways of doing things, such as Ruby, Rust and C#, all of which influenced Swift. In addition, old standbys like Python, also influenced Swift’s development.
One of Swift’s biggest advantages is its simple syntax when compared with other languages, including its predecessor. Swift also abandons Objective-C’s Smalltalk-style method calls in favor of dot notation, like the majority of other object-oriented languages. Swift also has improved security over Objective-C.
While not strictly an advantage over Objective-C, Swift handles memory management via Automatic Reference Counting (ARC). Objective-C added this in 2011, prior to which manual memory management was required. Thankfully, Swift brought this feature forward.
Another significant advantage is Swift’s backward compatibility. Apple has made Swift compatible with existing Objective-C libraries, an important factor considering how long Objective-C was the primary language for macOS and iOS development.
Given that Swift is so new, and incorporates the best features of a number of other languages, it is relatively easy-to-learn for new programmers.
Disadvantages of Swift
Despite its many advantages, Swift does have a couple of downsides.
One big disadvantage is no easy way to use C++ libraries directly in a Swift project. To do so, a developer must first use an Objective-C bridging header.
Another disadvantage is a higher compile time when compared with Objective-C, let alone other languages.
What Swift Developers Do
Obviously, the majority of Swift developers are working on software related to Apple devices. Swift developers create software for the iPhone, iPad, Apple Watch, Apple TV and Mac.
While it is true that other languages and frameworks exist that can be used for developing software that runs on Apple devices, generally speaking, Swift is the best choice and offers the deepest integration. The language has full access to Apple’s APIs, resulting in more “native” applications and unlocks functionality that third-party languages and frameworks struggle to achieve.
Swift is also beginning to find a place in server programming. In fact, according to Chris Bailey and Robert Dickerson, of the Swift@IBM team, Swift has a number of advantages over other languages. In tests, it matched Java for high-speed performance, easily besting Node.js and Ruby by a wide margin, while at the same time using less than half the memory of Java.
Swift: The Takeaway
While it may be the new kid on the block, Swift has clearly established itself as a force to be reckoned with in the programming community. The fact that it is Apple’s language of choice has helped guarantee its widespread adoption and success.
At the same time, the language has a number of features that make it ideally suited for the task at hand, while also finding uses in other fields, such as server development.
Given the popularity of Apple’s products, it’s safe to say that Swift is not going anywhere anytime soon. The language has a bright future ahead, and any developer would do well to invest in learning it. Check out the Swift homepage for more info.