While a new year inspires many people to read more books or lose that holiday weight, it inspires us to push our mobile app development platforms forward. In 2017, we are committed to using Swift (touted as the language of the future) with a vengeance. If you are also keen on refactoring your existing code and are planning to gradually transition from Objective-C to Swift, you may want to spend a few minutes and understand what Swift really is, where it came from and where it’s headed.
The Origin of Swift
Developers use programming languages to develop new tools to better the lives of their users. Occasionally, developers need to develop new tools for themselves. OS X and iOS are both heavily reliant on Objective-C, a language that has been in use for more than 30 years, and is built on C, which has been around for more than 40. With the speed of programming development around the world, the time has come for the next step.
So, in 2010, Chris Lattner (currently the Director of Apple’s Developer Tools) and a core team of developers secretly started to work on a new language, Swift. If you can’t place who Chris Lattner is, he is the same guy who worked on the Low Level Virtual Machine (LLVM) compiler infrastructure project – the one with a wyvern dragon mascot.
Their goal was to develop a cleaner code with a simpler syntax. While drawing heavily from Objective-C, the language was influenced by many others, including Rust, Ruby, Haskell, Objective-C, C#, CLU and Python. Notably, and outside the norm for Apple, the language has also had open source development — which has enhanced both the capabilities of the language and the community engagement with it.
Swift was introduced during WWDC Keynote in June, 2014. The initial release was in beta but shortly after, version 1.0 was officially adopted for app development. The language remained in flux and kept evolving throughout 2015 — until the current version, 3.0 — which was released in September 2016. Version 3.1 is expected in the Spring of 2017, with work then beginning on Swift 4.
Why hasn’t Swift achieved mass adoption?
As a language, Swift has seemingly appeared out of nowhere, and is not without its flaws. With each of these releases, there have been numerous concerns about the code breaking, and this has made some developers hesitant to adopt it. Supporters argue that any issues that developers face with migrating to Swift are to be expected, just as you would expect issues with each new operating system.
It is true that Swift has not yet been heavily adopted for iOS or the most popular apps, but there are many third party developers who have enthusiastically taken it up. The main reason that Swift has yet to be adopted in operating systems and popular apps is simply time. The language is still very young, and definitely wasn’t a realistic basis for an operating system (nor a heavily used app) until recently. Up until now, Swift has only been trusted with smaller, non-critical parts of development that are open to experimentation. As the language matures and stabilizes, it will be taken into core functions.
The future of Swift:
The important thing to consider now is that Swift is popular, and developers are excited about it. It’s moving in the right direction: Swift came in at 13th in the Dec 2016 TIOBE Index, up from 14th in 2015. Objective-C made a surprise comeback — jumping from 15th to 11th — but is only marginally ahead of its younger counterpart. With the years behind it, and the sheer volume of usage, Objective-C should have been much further ahead in the ranking if it were to continue as the dominant language much longer. But its position indicates that very soon it may become obsolete and be completely replaced by Swift.
Why we love it:
Swift is, well, swift. It fulfills a developer’s need for speed and that is its most promising characteristic. Techniques like compile time method binding, strong typing, compile time optimization and memory layout optimization make Swift an incredibly fast language.
Besides its potential to achieve a higher level of performance than Objective-C, what really sets it apart is its set of features that render it clean and beautiful. Features like type inference, clean closure syntax, default parameter values, external names, subscripts, memberwise initializers, etc. make writing and reading code in Swift much easier. If you want to see what I mean by cleanliness, try writing a piece of code in Objective-C and then in Swift — you will be able to spot the differences for yourself.
Swift also scores well with its Interoperability with Objective C. Swift is designed to provide seamless compatibility with Cocoa and Objective-C: you can use Objective-C APIs in Swift, and you can use Swift APIs in Objective-C. This makes Swift an easy, convenient, and powerful tool to integrate into your development workflow. What’s more – even Facebook, Uber and Google are considering making Swift central to their operations.
Which one should you learn first?
With Apple’s determination to get Swift out there and adopted, it is plain to see that Objective-C’s days are numbered. With that in mind, potential iOS programmers may find themselves asking which will be more beneficial to learn first; Objective-C or Swift. Ultimately, Swift is the future, but Objective-C is going to be around for years to come. Legacy systems invariably linger, because replacing things that work reasonably well is not realistic. This means you will need to know how to operate in both environments.
Objective-C isn’t going to change drastically and there will be plenty of time to catch up and learn about it later. For now, getting an early start on Swift will put you in a solid position to stay ahead of the app development curve. Once you’re comfortable with Swift, you can turn your attention to learning Objective-C and regularly check up on new developments with Swift.
The announcement of Apple at WWDC 2015 to make Swift open source is another great reason to get started with it. This means that Swift can be used to write any software and will not be used exclusively for the development of writing iOS or OS X apps. In fact, tinkerers have already begun using it to create command-line scripts as a replacement or supplement of the existing scripting languages, such as Python or Ruby. Here’s a list of some amazing open source apps written in Swift.
Where to start learning Swift?
Apple really want you to enjoy using Swift, so they built playgrounds! That seems as good a place as any to experiment and play with the language and get yourself set with the basics.
Once you have an understanding of Swift, you’ll have a handy new tool that can build other tools. But remember that learning the basics of Swift is only the first step. You have to progress to higher levels of competence before you can build a remarkable mobile app.
“Developing a mobile app is like building a table. You can learn the basics of woodworking and nail a few pieces of wood together to make a functional table but you are very limited in what you can do, because you lack advanced woodworking skills. If you want to make a truly great table, you need to focus on developing your skillset.”
Looking for a partner to build your iOS app?