Why learn Swift? The creation and evolution of a new programming language
June 02, 2017 | Károly Nyisztor
Almost everybody expected incremental changes and enhancements of the Objective-C language. Instead, Apple decided to create a new programming language from scratch: Swift is free of all the legacy Objective-C has accumulated, yet Swift and Objective-C code are meant to live side-by-side to make the transition easier. And, in less than three years after its public announcement, Swift made it into the top 10 most popular programming languages as reported by the TIOBE Index in March 2017, and was named as the second fastest-growing skill in Q4 2016.
Undoubtedly, Apple has big plans for Swift. So, even if you aren’t developing iOS or MacOS apps yet, learning Swift allows you to enter Linux, server-side development and probably systems programming, too. But to really understand Swift and its value, let’s delve into the history of Swift and what is the foreseeable future.
Swift: Programming the beginnings of a new language
Chris Lattner is the man behind Swift, and he began developing this language during his time as a research assistant and Ph.D. student at the University of Illinois. His aim was to build a simple language that didn’t need a pre-processor and was free of all the C and C++ legacy. Chris began working on this language in the form of a research project called LLVM, a modular toolkit for building compilers. He planned to finish the project by the time he graduated, but it was far from being production ready. To fulfill his dream and make a real product out of LLVM, Chris went looking for a place that would let him work on LLVM. He found this place in Apple, where they hired him to bring LLVM to production quality.
The side project called Swift
Originally, it was just Chris experimenting and playing around with his side project on nights and weekends. But, as the project started to take shape, management and more engineers become involved. At that time, the project was still rather an experiment than a major commitment. Eventually, the Swift project evolved to a point where it could not be treated as a side project anymore. However, Swift’s future was not decided yet. And there was still the ever-lingering question of Objective-C.
Why not just improve Objective-C?
There was Objective-C, a battle-proven, high-performance programming language. So, why not evolve Objective-C – the programming language used by the entire Apple development community – instead of creating a new one from scratch?
Apple continued to bring considerable improvements to Objective-C, such as automatic memory management with ARC, literals, etc. (As a matter of fact, many of the Objective-C enhancements were made to bring Objective-C closer to the – still super-secret – Swift language.) But there was one core issue that could not be solved with incremental changes: Objective-C is unsafe.
Objective-C is a superset of the C language—it’s built on top of C. And while C is a great programming language, it does not prevent developers from writing insecure code.
After many discussions, it became apparent that creating a new programming language was the way to go—a modern language that is performant, has a clean syntax and provides a safe memory management model. In June 2013, the official decision was made: Swift development should go on with the involvement of the Apple development tools team.
At WWDC14, Apple announced Swift. It was a big surprise. Nobody anticipated such a bold move from Apple. And we loved it right away, since it brought a modern syntax and useful language features that weren’t available in Objective-C: tuples, closures, enums and structs that support methods, generics, optionals, just to name a few. A Swift beta version was made available to registered developers at the conference. The beta version did not guarantee source compatibility, which allowed Apple engineers to further enhance the language until the official release of Swift 1.0 in September 2014.
Swift goes open source
Since Swift was released, it’s been continuously evolving and changing. About a year after its initial release, Swift 2.0 was announced, also at WWDC15. This time around, the language had some major changes.
In December 2015, Swift 2.2 was made open source. Yet another surprising – and smart – move from Apple, which gave a huge boost to the evolution of the programming language.
However, as Swift became open source, a lot of people started asking questions and challenged decisions made by the core Swift team: The amount of submitted proposals and bug-fixes was overwhelming. The unforeseen communication overhead caused some turbulence at first. It was a scary experience for the team: They were not prepared for the crowd of excited people and potential contributors.
But the benefits of going open source were undeniable. And now, a large community of professional developers have actively contributed, and they’ve helped in moving Swift to where it stands today.
Breaking the legacy: Swift 3.0
Swift 3 was officially released in September 2016. This has been the biggest upgrade so far and made Swift really true to itself. It brought fundamental changes to the language and the Swift standard library.
Apple provides a migration guide along with API design guidelines to make the transition easier. Xcode 8 comes with an automated migrator, which helps convert projects written in previous Swift versions.
What’s next for Swift?
While Chris Lattner left Apple and went to Tesla earlier this year, but this move shouldn’t affect the development of Swift. Swift is no longer a one-person project, and Chris continues to be involved with the design and helps the core team with the Swift-evolution project. Ted Kremenek became the new lead for the Swift project.
Apple wants Swift to be the next big thing, and going open source was part of this strategy. And in my opinion, Swift should not only become the language of preference for iOS and Mac development, but the language for server-side and systems programming.
If you're interested in learning more about this increasingly popular language, be sure to check out Swift courses on Pluralsight.