Apple has a long history with the Objective-C programming language. In February 1997, it acquired Steve Jobs’ company, NeXT, which employed Objective-C since the late 80s as the programming language of choice for the development of its operating system, NeXTStep. Since NeXTStep became the basis for Apple’s MacOS X, Objective-C also became the language of choice for Apple development. It was the programming language of the MacOS and the iOS. It remained on top for the next 17 years, reaching a point where it became one of the most popular programming languages in use.

It all started to change with the announcement of Swift in the keynote of WWDC 2014. At the time, Craig Federighi, Apple’s VP of Software Engineering stated that ``We’ve used Objective-C for 20 years, and we love it. But we wondered what we could do without the baggage of C.’’ Fast-forward one year and in WWDC 2015’s keynote (about 69m15s in), the same Federighi announced that Swift 2, which would still be released in 2015, would be open source. This was very big news. The size of the cheer that those news got from the public at WWDC hints at their impact. I was cheering like a fanboy as well. However, as is usually the case, in retrospect, this was an obvious decision, one that should have been taken a long time ago.

Enabling vs. Differentiating

In his 2005 article, The Emerging Economic Paradigm of Open Source, Bruce Perens, one of the creators of the Open Source Definition and of the Debian Social Contract, highlighted two different roles that software takes within an organization. It may be an enabling technology or a business differentiation. Enabling technologies help an organization to operate. The organization does not directly profit from enabling technologies, nor differentiates itself from competition. Instead, enabling technologies are cost centers that the organization has to bear in order reach its business goals.

A representative example of enabling technology is Microsoft Office. It may be useful for a company to be more productive, but any company with resources to acquire it can benefit from that added productivity. Less obvious examples are infrastructure software necessary to run businesses like Facebook, Google, and Amazon. Since their infrastructures operate on a scale never seen before, they cannot simply acquire their infrastructure software and must build much of it in-house. However this kind of software is still a cost center. For example, even though Facebook’s Cassandra is a very sophisticated distributed storage system, Facebook’s business does not center around this technology. The same goes for Amazon’s DynamoDB storage system. On the other hand, some pieces of infrastructure are clearly business differentiators. Examples include the most sophisticated parts of Google’s search engine software and Amazon’s recommendation system. Much of the profit from these companies comes from the very good jobs these pieces of differentiating technology perform. The same goes for Microsoft Office, from Microsoft’s perspective. Much of its profit comes from both the retail and service-based versions of Office. For users, Office is an enabling technology but, for Microsoft, it is a business differentiator. Perens summarizes this point in his article:

``An important indicator of whether software is differentiating is whether or not your competitor can get the same software. Neither Microsoft software nor Linux and Open Source can help you differentiate your business for long, because they are available to everyone. They differentiate against each other, they just don’t differentiate your business.’’

Back to Swift

Why is this distinction between Enabling Software and Differentiating Software important? Because enabling software should always be open source, since an organization does not profit from not making it so. Since enabling software is a cost center, making it open source distributes costs and risks between the organization owning the software and the larger community that may have an interest on it. This community may comprise independent developers, governments, non-profits, and for-profit organizations. It helps disseminate software and improve it, making it more portable, more reliable, more well-known, and more widely used. This is the reasoning behind the decisions of organizations such as Facebook, Google, and Microsoft when making software technologies such as Cassandra, Android, and .NET open source.

It is no surprise, thus, that last Friday, December 4th 2015, Apple has made Swift open source. It is easy to see that when we analyze Apple’s earnings reports. MacRumors compiled a nice graph breaking down the contributions of different sources of revenue to Apple’s overall earnings. According to this graph, the vast majority of Apple’s revenue in the last few years came from iPhone sales, followed by Mac sales, and a broad category named Services, which covers the iTunes store, the App Store and, more recently, Apple Music. In other words, Apple is mainly a hardware company (iPhone, Mac, iPad) which also profits from services. It is in its best interest to have as much high quality software as possible in its platforms (iOS, MacOS and, more recently, watchOS and tvOS) because this makes them more valuable. Hence, it is fair to say that to Apple, Swift is an enabling technology.

One interesting question, in this context, is why haven’t Apple made Objective-C open source, instead of proposing a new language. Well, I have no good answer for that, but there are at least two obvious (again :) factors. The first one is that Objective-C is a painful language. Simply typing “Objective-C sucks” in Google shows that this opinion is shared by more than a few developers. In contrast, if one types “Java sucks” in Google, although quite a few results do show up, some of them are actually defending Java, instead of attacking it. The second one is that even Apple believes that Objective-C has overstayed its welcome. Craig Federighi described Swift as a language to be used in the next 20 years. I may be seeing too much here, but 20 years is approximately the time Apple has spent with Objective-C. Maybe a company that is almost universally seen is very innovative does not want to be thought of as a company that cannot let go of old technology. Thus, simply making Objective-C open source would not make the cut. A new language would be necessary first, one that could address some of the shortcomings of Objective-C development.

Open source Swift is great news!

Besides being obvious, I also think that Apple making Swift open source is great news. First of all because it will make the language more widely available (even Linux is supported). Swift is, IMHO, so far the language which best integrates object-oriented and functional programming. The two approaches merge seamlessly and synergistically. Swift has classes, protocols, protocol extensions, algebraic datatypes disguised as enumerations, Maybes (Optionals), closures, and partial function application. Having the source code available makes it possible to experiment with these features (and new ones) on a completely different level. How long until we have the first object-oriented programming language supporting full-fledged monads?

Open source Swift is also desirable for researchers. They won’t have such a hard time conducting studies targeting the Apple ecosystem, since there’ll be tools allowing us to analyze programs for this ecosystem. For example, prior to December 4th, to conduct a simple study to collect basic object-oriented programming quality metrics from Swift programs, one would have to build a lexer, a parser and, depending on the degree of precision desired, a type checker. Now, all of this comes for free. A researcher can focus on the information she actually wants to gather and abstract way the basics.

An additional reason why going open source is great news for Swift is that the community can take control. Being open source means that Swift is forkable. In Github, a simple press of a button produces a complete copy of the entire Swift codebase that can envolve independently from Apple’s version. This allows for free experimentation with the language’s toolset, improving this toolset and making it available in new platforms. It makes me wonder when the first Android app written entirely in Swift will become available.

It is also worth considering the choice of license for Swift. Apple has selected the Apache License v.2.0. This is a permissive open source license, which means that developers are free to not only execute, read, modify, and distribute the source code of Swift, but also to close the source code if they believe this can be beneficial. This is good because this kind of license allows all the community to benefit, not only those who defend open source. Moreover, it is to some extent consistent with Apple’s past interactions with open source in the context of the Darwin operating system, which was an amalgam of NeXTStep and the BSD operating systems. The later uses the BSD license, which is also permissive. Darwin was distributed according to the Apple Public Source license, not a permissive license but still not a strong copyleft license, such as the GPL. Darwin was the basis for the first versions of the MacOS X operating system.

Concluding

In retrospect, Swift should have been open-sourced from the outset. It wasn’t but Apple has quickly fixed this mistake. Now a world of possibilities is open for developers and researchers interested in Apple’s ecosystem. Some of my students and colleagues have already started pursuing research targeting Swift and I am excited to see what will appear in the next few years.