Why Learn Swift?

Swift is a programming language released by Apple in 2014. It was designed for a wide range of uses, from mobile and desktop applications (iPhone, iPad, Apple Watch, Apple TV, Mac) to websites, web applications, and APIs* to operating systems and more. In fact, the website you are currently reading was written in Swift.

Learning a programming language is like learning a foreign language. There are many to choose from, and without a specific goal it can be hard to know where to start. If you want to study abroad in Spain, it's logical that you would study Spanish. If you have a significant other whose native language is Chinese, you'll probably want to learn Chinese. But for some, the goal may be to become bilingual, study linguistics, or work as a translator. They are interested in language as a skill, and may not have a specific application in mind yet. They use other factors to make their decision, such as number of native speakers, ease of learning, or demand in the job market.

Deciding which programming language to learn can be approached similarly. If you're interested in data science, you may choose R or Python. If you want to build a native Android app, your best bet is Java. For Apple devices, the clear choice is Swift.

But what if you just want to learn how to code, whether as a hobby or with the goal of getting a job as a software engineer? I would argue Swift is a great first language for anyone with this general interest in programming and computer science. Why?

Swift Is Safe

One of Apple's primary goals in designing Swift was to facilitate and encourage "safe" code. What does that mean? We've all had a computer program crash on us or leak memory and slow down our device. No programming language can eliminate crashes or memory leaks, but Swift is designed to prevent programmers from making many of the common mistakes that cause these problems. Swift does this by being very strict. Swift's compiler (a software program that converts code into a machine language that your computer can understand) constantly checks your code for errors and requires you to fix them before you can run your program.

This built-in rigidity is great for new programmers. The compiler acts as a coach, providing regular feedback and enforcing good habits. Swift may be more difficult to learn at first, but its design requires programmers to learn valuable computer science concepts and patterns that are essential as they begin to tackle more difficult problems.

Swift Is Evolving

The most recent version of Swift at the time of this writing is 4.0, released in June 2017. It is very different from 1.0, in part because Apple has devoted its own vast resources to improving it, but also because they made the language open source. Open source software is code that the copyright holder has released under a more permissive license. This allows the software to be developed publicly by a large community of engineers and modified for uses beyond the creator's original intent.

The combination of an open source license, Apple's investment, and the global reach of Apple's products helps keep Swift modern and versatile. For new programmers it's an unprecedented opportunity to see a language evolve as they learn it. For experienced programmers it's an unprecedented opportunity to contribute to a language with massive scale and impact.

Swift Is Expanding

You probably don't need to be convinced that Swift engineers are in demand. The enormous success of Apple devices and the App Store has created countless jobs. But I predict that usage of Swift will continue to expand at a fast pace over the next few years, both within and beyond the Apple ecosystem, further increasing demand for Swift engineers.

There are already three prominent Swift frameworks for building web apps and APIs, including Vapor (used to build this website), IBM's Kitura, and Perfect. These frameworks make it possible to write a mobile or desktop application with a server component entirely in Swift. Especially for companies whose primary product is an iOS app, the prospect of using one language throughout the codebase is compelling.

If you have a specific problem you want to solve or a passion for a particular platform, you should choose the programming language that best accomplishes your goal. However, if your goal is to enter the world of programming and start on the path to becoming a software engineer, I hope this article has convinced you that Swift is a great choice.

* The terms "website", "web application", and "API" can be thought of as follows. A "website" delivers the same content to all users. You are currently reading a website. Another example is a news site. A "web application" displays a mix of content available to all users and interactive content that the user either created or is specific to the user. Examples include Gmail and Facebook. An "API" (Application Programming Interface) in this context is an application run on a server that provides data to an application and processes input data from that application and other sources. Most of the applications you use, whether on a mobile device, desktop computer, or web browser are powered by APIs. When you write a post on social media, you are using a web or mobile application that in turn uses an API to create and store that post. Your friends are using the same web or mobile application and the same API to view that post. Engineers use APIs directly to power their own applications.