Introduction to Swift Get to know the main programming language for iOS development.
In this article, we will introduce you to Swift, its past and its future, and give you reasons why you should start thinking about learning the language and/or building Swift projects.
What is Swift?
First released in 2014, Swift is a powerful general-purpose programming language for the Apple ecosystem. Whether you need to develop for iOS or any of the surrounding operating systems like macOS, tvOS, and others, it will be one of the main tools in your toolbelt.
On the other side, Swift’s clear and expressive syntax enables developers to write more concise programs than in languages like Java or C++.
While it’s being used mainly for Apple products, Swift has recently got some market share in areas like machine learning and web. For example, TensorFlow added Swift support because of the increased speed and type safety over Python, while server-side web frameworks like Vapor and Kitura are slowly gaining popularity.
A brief history of Swift
The development of Swift started in 2010. At that time, Chris Lattner (the creator of LLVM and Clang) had just finished adding C++ support for Clang, a compiler for the C-like language family. He was a bit burned out on C and decided that there was a better way of doing development.
Together with Bertrand Serlet, the head of the Apple software team, they came to a new, better alternative to Objective-C through numerous whiteboard sessions. In the beginning, the language was called Shiny (as in “this new shiny thing”).
More than a year later, Lattner shared his project with his colleagues and managers at Apple. They admired the work Chris had done and assigned a team of developers to continue the project.
A lot of the features(like ARC) that were added to Objective-C at that time actually came from Swift, and the team was considering just slowly upgrading Objective-C. But unfortunately, one of the main features of Swift is its memory safety. And if one takes memory management out of a C-like language, there’s not a whole lot of C left in it. Therefore, they started on a path towards Swift.
Announcement and open-source release
Swift was finally announced at Apple WWDC 14 as “Objective-C without C”. You can see the full announcement video.
At the start, it wasn’t open source. But, on December 3, 2015, the Swift version 2.2 was made open-source under the Apache License 2.0. for Apple's platforms and Linux.
Fight for stability
Through version 3.0, Swift had some stability issues. It was frequently changed in backward-incompatible ways, leading to older tutorials being too outdated to use.
In addition, the programs written in one version of Swift had problems working together with ones written in another version of Swift. This problem was solved when Swift 5 introduced ABI stability.
But all in all, the core team has expressed that source code compatibility is essential for them at this moment of Swift’s journey, so problems like these shouldn’t be a thing anymore. Swift is a mature language now and is very well suited for both small and large projects.
Future of Swift
Right now, Swift is in 9th place in the PYPL index, just below its predecessor. It’s widely used for development in the Apple ecosystem, and it is quite clear that Apple itself has moved on from Objective-C to Swift as their language of choice for the future.
What’s more, Swift engineers are in high demand among technology companies. Application developers are one of the most sought-after professions in the job market, and Swift is the main app programming language for iOS. Because Apple cares about Swift, it will continue to improve it for a long time and promote it to the top of the programming languages.
There is also a flip side to that. The language and its users are heavily invested in the Apple ecosystem, and its future highly depends on the future of Apple. Fortunately, the language’s open-source nature enables developers to diversify against threats like that by creating frameworks and applications for Swift outside the Apple ecosystem.
Swift vs. other alternatives
Since thinking about Swift as the programming language of choice usually means that you are operating in the Apple ecosystem, it’s not that useful to compare Swift to most other modern programming languages. However, Swift does have quite a lot of strong points such as safety and ease of use that makes it as good of a language as other modern programming languages like Rust.
Therefore, we will look at the situation where you are building an application for an Apple product, such as an iOS app. In that case, you have two choices that are not Swift.
Objective-C is a superset of the C programming language with OOP capabilities and a dynamic runtime. It was the language of choice for Apple products before, and multiple legacy codebases still use it.
Even though it is more popular according to the PYPL index that tracks searches for language tutorials, it’s clear that Objective-C is in slow decline. Most of the things that Objective-C can do, Swift can do in a more accessible and safer way, so it is not wise to start most of the new projects in Objective-C.
There are multiple cross-platform frameworks out there that enable developers to develop for Android and iOS systems at the same time. Among them, we can list React Native, Flutter, Xamarin, and others.
These are a pragmatic choice if you need to quickly launch a simple app on both platforms, but do bring performance costs and can raise some problems if you need non-standard components for your app that the framework does not support. If you do not take care when deciding on cross-platform vs. native, you might end up doing three times the work instead of saving half of it.
Swift as the first programming language
Each programming language has its unique characteristics, strengths, and weaknesses. Among Swift’s benefits are its practicality and increased developer productivity, enabling developers to quickly create prototypes and MVPs. At the same time, Swift is a powerful tool for building large applications like Twitter or Waze.
Many developers consider Swift to be a wonderful choice for the first programming language. Apple and the Swift community have put a lot of time and effort into creating easy-to-read documentation, high-quality instructive content, and a supportive environment for new Swift developers.
If you are a new developer thinking about which language to start with, here are some arguments in its favor:
- If you’re a solopreneur, creating programs for Apple devices gives you access to a well-paying audience of Apple Store users.
- If you prefer working as a hired specialist, knowing Swift on an intermediate level already allows you to earn from $2000 per month (depending on the country you live and work in).
- Apple is a cutting-edge technology giant, which means you'll always be able to work and experiment with modern tools, features, and libraries.
- Swift is used for writing programs for a range of Apple devices, so having learned one language, you can work on all of them.
- Thanks to the Swift programming language's community, Swift is relatively easy to learn. You can easily find a large amount of free quality Swift content on the Internet.
- Today, there are more than 3 400 000 apps in the App Store. Of course, not all of them are native and written in Swift, but it is safe to say that a least half of them are Swift-based. In 2019, the number of apps was just 3 000 000, and the statistics show constant exponential growth. This will undoubtedly lead to a higher demand for Swift developers.
Starting with Swift
There are multiple great resources available to learn more about Swift. Here are a few:
- Swift Programming Language. The official Swift book that will give you all the info you need to start creating your own iOS project.
- Learn Swift Fast. If you learn better through video, there’s a 3-hour video course on YouTube that will cover all the Swift basics.
- Hacking With Swift. A website that hosts Swift content, including articles, news, example code, and much more.
- Exercism Swift track. Eighty-three exercises that will let you boost your Swift skills and receive feedback from experienced mentors, all for free.