Main image of article Is 2021 When Swift Programming Language Goes More Mainstream?

Apple debuted the Swift programming language in 2014, and it quickly grabbed the interest of developers everywhere. Over the past few years, it’s birthed a whole sub-industry of merchandise, Udemy classes, and even bespoke conferences dedicated to the language—not exactly surprising, when you consider how the language is becoming the best path for building macOS and iOS apps.

TIOBE’s latest ranking shows that Swift’s use is outpacing the aging language it is meant to replace, Objective-C. However, multiple programming-language rankings (including analyst firm Redmonk’s) show that Objective-C is managing to hold on, probably because there’s a lot of legacy code out there that must be maintained (shifting everything to Swift is a time- and money-consuming process that must be done carefully). 

Earlier this year, the Swift.org open source team made several interesting announcements, including Windows support, better interoperability with C via Swift Systems, and the ability to utilize atomic operations in a codebase. Swift 5.3, the latest iteration of the language, was also retooled to compile faster.

Six years in, Swift hasn’t supplanted Objective-C as many expected it would. Is 2021 the year that this language finally breaks through in a more mainstream way? We asked some experts what they thought.

The Pros

Mohammad Azam, Lead Full Stack Immersive Web instructor at DigitalCrafts and an Udemy instructor, points out how Swift now has all the components of other major languages: “[Swift] consists of features like optionals, closures, optional function arguments, and protocols.”

It wasn’t always like that, and you can find some great accounts of how companies jumped quickly to embrace the first few versions, only to ram into unexpected difficulties. But now things are maturing. Paweł Kozielecki, iOS Tech Lead at Netguru, agrees with Azam that optionals “are a great programming concept, allowing you to not only prevent crashes, but also to enforce clean code across your application.” 

Kozielecki says that Swift’s use of extensions is also important: “Extensions (initially known as Categories in Objective-C days) are a great way to add additional functionality to an object, without a necessity to extend it or build a wrapper around it. Categories add a set of methods or computable variables to a class in runtime (that is: after the class itself has been compiled).”

What is even more significant, Kozielecki adds, is how “protocols in Swift also can be extended (a.k.a. Protocol Extensions, also called default implementations for convenience). Such extensions can implement selected methods from the definition of a given protocol, greatly decreasing an amount of code a developer has to implement to conform to that protocol.”

Readability and frameworks are also key, according to Bear Cahill, Lead Mobile Developer and President at Brainwash and a Lynda instructor: “Both of these attributes help Swift to be highly maintainable. Also, the code can often be written with optimizations (e.g., shorthand argument labels), which allow for concise code.”

Last but certainly not least, a growing community is a huge plus, lending structure and support. But what’s Swift lacking, if anything? While many developers like to speculate freely about which features the Swift team should add, our panel points out that team may have already overlooked some features and tweaks that could have given the language a much more dominant footprint within Apple’s walled garden.

The Cons

Cahill points out Swift 5.3’s compile time fixes may be—well, timely: “While Swift allows for quick development using LLVM, redeploying changes as a new build in the simulator/device is a glaring speed bump.” 

Azam suggests “Swift is a typed language, so it’s fast,” but Kozielecki isn’t sure that’s a net positive:

Compared to Kotlin or Java, Swift is not a reflective language (as it is statically typed). Swift offers a substitute - a Mirror functionality, but it is not the same. An object in Swift can “self-describe” (eg. get a list of its members) but cannot manipulate them from within. Through reflection, eg. it is easy to create Java classes mocks for testing, automatically inject dependencies, etc. It’d be a great feature in Swift, albeit very difficult to achieve.

Kozielecki goes on to note how the ABI architecture isn’t always reliable: “Despite the introduction of the Application Binary Interface in Swift 5.1, code compiled with different versions of Swift (eg. 5.1 and 5.2) often have problems working together. In the days of Objective-C, a piece of code could have been conveniently compiled into a static library, and easily introduced into a project as a dependency.”

In Swift, though, it wasn’t possible to produce static libraries until recently, which forced companies and developers to continue to use Objective-C if they didn’t want to expose their code. 

Azam adds: “Sometimes the strictness of [Swift] may get in the way of your work.”

While Windows support is coming, and Linux support exists, Cahill points out that Swift still doesn’t reach the most core technology for many developers out there: the web. “Despite being open-source and cross-platform, Swift doesn't have a well-known presence nor many supported IDEs,” Cahill says. “Being a compiled, versus interpreted, language may prevent it from being widely adopted in the web development community. Thus, it can suffer from an perception that it's ‘an iOS/Mac/Apple language.’"

We can pontificate endlessly on how Apple/the Swift team may solve for ‘x’ in these instances. Maybe the WYSIWYG energy of SwiftUI is the front-end web developer tooling that will compliment work with back-end Linux environments. Perhaps Swift will soon branch out from Xcode and become more usable in other IDEs. Perhaps improvements to Async will kick the language into high gear.

Swift is an Apple-only language, even though it works with other platforms and environments. Apple is also one of the most dynamic tech companies around, and its next big bet will be augmented reality (AR). The company hints that AR will be the next big paradigm shift in mobile, and perhaps tech as we know it. If that holds true, Swift will become an incredibly important language (and its use will skyrocket). That said, 2021 likely won’t be the year of AR, and Swift still has too much work to do to spring into a truly dominant position… both in the Apple ecosystem and beyond.