As if there weren’t enough programming languages out there, along comes one that has gone from zero to one of the most popular languages in only a couple of years. The language is Swift, designed to succeed Objective-C in the world of app development for iOS devices and their numerous relatives.
How did Swift come so far so fast, and where is it going next?
Swift: A Brief History
Any history of Swift is necessarily brief. First conceived in 2010 by Apple’s Chris Lattner, the first known sighting of Swift in the wild was its beta release in 2014, with the first production release appearing later that year. Development has been rapid since then, particularly since Apple turned the project over to open-source management in 2015. Swift retains significant support from Apple, with major contributions from IBM as well. At this writing, the current version of Swift is 4.2, with 5.0 waiting in the wings for release later this year.
Swift’s core design principles are:
- Simplicity. Swift is designed with a simple syntax. Most tasks require fewer lines of code than their equivalents in Objective-C.
- Safety. Swift’s design makes it harder to introduce bugs or security vulnerabilities in code.
- Performance. Swift is designed to run faster than Objective-C, and does in fact consistently achieve this goal.
In addition to those for the Apple ecosystem, a Swift compiler exists for Linux as well, and there are rumors of support for Windows in the future.
Pros and Cons of Swift
Swift has a number of advantages, with a few disadvantages that it needs to overcome.
- Pro: Swift was originally seen as an eventual replacement for Objective-C, the mainstay language for iOS, MacOS, and other Apple platforms. Knowing that this transition would be gradual, Apple designed Swift to interoperate with Objective-C. Both languages can be used within the same project, so updates to an app built in Objective-C can be implemented in Swift.
- Con: Because of its short history, and despite its popularity among developers, few developers have actual hands-on project experience with Swift. It may be a few years before there is a sizeable talent pool of Swift developers.
- Pro: Because of its simple syntax, Swift code is easy to write and easy to read and understand. Many tricky technical details are hidden from the developer, enabling developers to focus more on functionality and performance. In particular, memory management is handled behind the scenes by Swift’s Automatic Reference Counting (ARC) feature—a huge improvement over Objective-C, which requires developers to manually allocate and release memory for program objects.
- Con: In its short history, Swift has had several major releases, and they have suffered from a lack of backward compatibility. Programs written in earlier versions of Swift won’t compile in newer versions, meaning developers have to completely rewrite applications in order to take advantage of newer features. Many developers are waiting on the sidelines for Swift to become more stable, or at least have backward compatibility with more than just the immediately previous version.
- Pro: Although the cadre of experienced Swift developers is small, the community is enthusiastic, dedicated, and growing. Many resources are available for learning Swift, and the language boasts excellent documentation. Continued backing by Apple and IBM doesn’t hurt either.
- Con: Swift so far has poor support by developer tools and IDEs. Even Apple’s Xcode IDE lags behind Swift’s rapid development and release cycles, making it difficult to use with the latest Swift release.
The Future of Swift
Many of Swift’s disadvantages are simply symptoms of its young age. As time goes by, Swift will mature and become more stable. The real test will come when developers start building complex, business-critical applications with it and really test its limits. How well it meets these more stringent requirements may mean the difference between Swift becoming the next well-known, general purpose language (like C, C#, Python, or Java) or just another niche language with limited applicability and a small talent pool.
Meanwhile, the near future holds some excitement for Swift. Although Version 5 will not be binary compatible with earlier versions (meaning that code compiled with different versions won’t be able to interoperate at runtime), and will not compile code from Swift 3 or earlier, future releases will be both binary and source compatible with version 5—a sign of growing maturity for the language. In addition, IBM’s contributions are making Swift suitable for server-side coding, increasing the frontend/backend cohesiveness of client-server applications.
The future looks bright indeed for Swift, not just for Apple products and devices, but perhaps as a solid general-purpose language for all kinds of applications. At AndPlus, we’re excited to see these developments and to add Swift to our growing body of expertise.