Apple Open Sources Its Swift Programming Language

Apple's paving the way for Swift to run on all sorts of other machines---maybe even Android smartphones.
Web
Then One/WIRED

In a move that represents a significant shift for Apple—and for the tech industry as a whole—the world's most valuable company has open sourced its Swift programming language, freely sharing the underpinnings of this new and potentially powerful language with the world at large.

Apple unveiled Swift last year—much to the surprise of the broader programming community—offering the language as a significantly easier way of building applications for the iPhone, the iPad, and the Mac. But in open sourcing the language—something Apple had promised it would do—the company is paving the way for Swift to run on all sorts of other machines, including computer servers loaded with Linux, smartphones based on Google's Android mobile operating system, and tablets based on Microsoft's Windows operating system.

Apple says it will run the new open source project from a website called Swift.org, while sharing the source code through the popular code repository GitHub, and it has seeded the project with a wide range of tools. Most notably, it has open sourced Swift compilers that will run on Linux as well as Mac OS X. These let engineers transform raw Swift code into full-fledged applications. Apple has also shared Swift package managers that can format these apps so they will run on devices driven by Linux, Mac OS X (used on desktops and laptops), iOS (mobile), watchOS (Apple Watch), and tvOS (Apple TV).

Apple has not ported Swift to Android or Windows. But the code it has released should allow the open source community to build software that runs on both—and, potentially, on any other OS. Coders will be motivated to do so because Swift has already proven so effective in the world of iPhones and iPads. Apple built Swift as a language that is significantly easier to learn and use than its previous language, Objective-C, but that still provides much the same raw speed. Big name companies such as Twitter's Vine, Yahoo, and LinkedIn are already using the new language on Apple devices, and multiple companies, including startups Perfect and Exis, are already eyeing ways of running the language on other machines.

The Demand for Openness

An open source Swift is Apple's way of embracing a sweeping trend in the world of computer software. More and more, developers are using open source tools when building applications and online services—as are the tech industry's biggest corporations. Most notably, companies ranging from Google and Facebook to Uber and Airbnb run their online empires from vast data centers filled with Linux machines. And Linux is increasingly common on smartphones and other consumer devices. (Google's Android smartphone operating system is based on Linux).

"Open source is the currency of developers now," says Sean Stephens, the CEO of Perfect, a company looking to help run Swift on Linux servers in the data center. "It's how they share their thoughts and ideas. In the closed source world, developers don't have a lot of room to move."

On the one hand, this means popular software applications must run on more operating systems than in the past. But it also means developers have come to expect that fundamental coding tools will run everywhere, that these tools must be open source too, that they can be reshaped and reused in any environment. If Apple wants coders to embrace Swift—and continue building apps for Mac and iOS devices in large numbers—it must ensure that language runs on competing operating systems and devices. It did not do so with its previous programming language for the iPhone: Objective-C. But with Swift, it is.

"Apple open sourcing Swift is a fundamental change to what they have done in the past," says Dale Willis, CEO of Exis, another company that aims to build tools for running Swift in the data center. "It shows that they see this as a language that can really have a big effect on the future."

Microsoft made a similar move about a year ago with .NET, another common tools for building and operating websites and other large online applications. For years, .NET ran only on Windows, but in open sourcing the tool, Microsoft allowed it to run on Mac OS X and Linux as well.

As You Wish

Though Apple is maintaining a level of control over the open source project, it hopes to engage the broader community in significant ways. A good model is an older open source project called LLVM, which underpins Swift. Chris Lattner, the Apple engineer who created Swift, will oversee the new open source Swift project, just as he oversaw LLVM. But Apple intends to bring third parties into the group of project overseers—another echo of LLVM.

Apple's Swift.org will house the project's mailing lists as well as its bug reporting and tracking system, but the site will link to source code repositories on GitHub, which has become a primary way for coders to share and collaborate on software in general and open source software in particular.

In addition to compilers and package managers, Apple has shared the core Swift software libraries, the language documentation, and tutorials. It has released all source code under an Apache 2 open source license, which essentially means that anyone can use and modify the code as they please.

The Front and The Back

The upshot of the project is that coders are free to build and run Swift applications on a wider range of machines. They can run Swift code on both the consumer devices we hold in our hands and the computer servers that deliver the data and services to these devices. They can use Swift to build an app for your iPhone, and they can use it to build the software that drives that app from hundreds of Linux servers in a data center halfway around the world.

This too follows a larger trend. We're seeing more and more coding tools that let developers build software on both the front end (e.g. consumer devices) and the back end (servers). A tool called Node.js lets coders build server software in Javascript, the language originally designed for building applications within web browsers. Java—not to be confused with Javascript—is the primary means of building apps on Android smartphones, but it's also an important means of building the data center software that backs modern web services. In open sourcing Swift, Apple hopes to bootstrap another way for spanning both the front and the back end. "This can give people an alternative to Java," Stephens says.

That would put Swift in competition with Google's new language, Go, as well as the up-and-coming languages Rust and D. All are approaching much the same goal.

Like Go and Rust and D, Swift is seeking a new coding sweet spot. All four languages are designed so that coders can not only build software capable of rapidly juggling myriad tasks at once, but build that software rather quickly. In the past, software development wasn't like this. You used a language like C++ if you wanted to build software that executed at speed. And you used something like PHP or Ruby if you wanted build software quickly. In the Internet age, however, you want a language that does both, particularly when you're using the same language on the back end (where execution speed is so important) and front end (where there's pressure to constantly build new apps and new versions of apps).

Like Go and Rust and D, Swift aims to be this language. And now that it's open source, it can be.