What is the Swift programming language, and why should I learn it?

Apple Swift code logo

Swift has been around for decades, and has succeeded Objective-C as Apple’s go-to programming language of choice. It’s the only way to write code if you want your app to work on Apple’s device ecosystem, avoiding any compatibility issues or workarounds for them.

The uninitiated are often left confused when it comes to the differences between Swift and SwiftUI; the two work in tandem to build apps for Apple’s hardware. The former is the core language that defines the functionality and basic user interface (UI) of an iOS, iPadOS, macOS, watchOS, or tvOS app, while SwiftUI is a framework that lets users get more creative when it comes to building UIs. A reductive way of looking at things would be to say: SwiftUI is to Swift as CSS is to HTML.

Swift has come on leaps and bounds in recent years, not just in functionality but in popularity too. The popular programming language has steadily climbed rankings like the TIOBE index and is often viewed as one of the top ten most in-demand skills for software developers in today’s market.

Before Swift, Objective-C was the default programming language for Apple hardware but, over time, Apple instead adopted Swift which is largely based on Objective-C. There are still examples of pure Objective-C code in Swift, too, and to use them developers have to use special ‘objc’ annotation syntax so Swift can read and compile it properly.

Swift inherits a lot from its forefather but also from other languages too, like Python, Rust, and Ruby. In recent years, Apple has focused on improving Swift, and SwiftUI, to make it as easy as possible for developers to use and build great applications for its various platforms.

Can you use Swift on Windows?

It wasn’t until September 2020 that developers using Windows hardware could actually program using Swift. Until that point, it was a feat only achievable using Apple’s Xcode integrated developer environment (IDE), which itself can only be downloaded on Apple hardware. It was a case of ‘buy a Mac or turn right back’.

Swift released the toolchain images for Windows on 22 September 2020 and it took the open-source project longer than a year to port Swift over to Windows. It involved porting the compiler, as well as the standard library, and the core libraries too, which took a great deal of time to ensure developers had the best experience possible. To bring Swift to Windows, developers should use a toolchain installer and the Visual Studio IDE.

What can I build with Swift?

RELATED RESOURCE

Optimising storage infrastructure for DevOps practices

Maintaining IT infrastructure to best support application services

FREE DOWNLOAD

An example of an app built with Swift is Lyft, with ride-hailing company having completely re-wrote its iOS app using the programming language. While the old codebase consisted of about 75,000 lines of code, the Swift version recreated the same functionality with less than a third of that. Moving to Swift also allowed the app to feature app a new onboarding process; while the old one took more than a month and multiple engineers to implement, the new onboarding with Swift was completed within a week with only one engineer.

Other popular iOS apps built using the Swift programming language include Firefox, LinkedIn, Twitter and WhatsApp.

How to learn Swift programming

Understandably, Apple is keen to get as many people as possible to a point of familiarity with its homebrew language, and it has a series of training resources in order to support this. One such resource is Swift Playgrounds - a free iPad app which helps teach kids the fundamentals of Swift programming through a series of games and challenges.

For complete beginners to the world of programming, this may be a good place to start, but it's probably a little on the simple side for all but the most novice developers. There are e-books and other official Apple resources available for more advanced learners, as well as numerous online courses for learning Swift.

Once you're familiar with Swift, the easiest way to start actually using it to build apps is to download the latest version of Xcode, Apple's IDE for macOS. This includes all the essential tools like a code editor, debugger, testing environments and more, as well as a full version of Swift and all the runtimes you'll need to start constructing apps.

Adam Shepherd

Adam Shepherd has been a technology journalist since 2015, covering everything from cloud storage and security, to smartphones and servers. Over the course of his career, he’s seen the spread of 5G, the growing ubiquity of wireless devices, and the start of the connected revolution. He’s also been to more trade shows and technology conferences than he cares to count.

Adam is an avid follower of the latest hardware innovations, and he is never happier than when tinkering with complex network configurations, or exploring a new Linux distro. He was also previously a co-host on the ITPro Podcast, where he was often found ranting about his love of strange gadgets, his disdain for Windows Mobile, and everything in between.

You can find Adam tweeting about enterprise technology (or more often bad jokes) @AdamShepherUK.