Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.
Apple's new programming language modernizes iOS development by synthesizing great ideas invented elsewhere
What Apple borrowed in creating Swift
To paraphrase the saying, good artists borrow, but great ones steal. However you look at it, Apple has nicked a number of features in creating Swift, its recently unveiled programming language for iOS. Swift may technically be "new," but look closely at the documentation, and you'll see Swift more as a collection of popular ideas employed in other programming languages, mashed together under a new name.
Following are the most prominent features of Swift and a glimpse at their origins, which often includes a chain of languages going back decades. This chain isn't definitive; in many cases the source of Swift's inspiration borrowed the idea from yet an earlier language. It's a long tradition of innovation.
The illustrations are from the Swift documentation.
Inferred data types -- from functional programming languages
Forcing variables to stick to a particular data type is an efficient way for programmers to catch bugs before the code even runs. The compiler checks data types and flags incompatibilities.
Of course, in modern programming, no one wants to spend all of those keystrokes specifying data types for every variable. Lately some of the best compilers have started inferring types from the data, which is usually easy to do when a variable is initialized. This began with some of the functional languages, like ML, and has since appeared in Haskell, Scala, and Opa, among others. Now that Microsoft added the feature to Version 3.0 of .Net, it's practically mainstream. Thanks to Swift, iOS developers can now save a few keystrokes, too.
Data structure declarations -- from C# and Java
What kind of data is stored in a data structure? Java introduced Generic types in Version 5 so that programmers could tell the compiler which data type will be pushed into the HashMaps, Arrays, or Collections. The greater-than and less-than symbols, aka angle brackets, specified what types would go inside. Around the same time, Microsoft added them to C#. Now it's Swift's turn to let programmers tell the compiler what to expect.
String templating -- from Cold Fusion, JSP, and others
Maybe computers worked with numbers long ago, but today it seems like most of a programmer's job is to glue together strings. Many programming tools offer ways to insert a variable's value into a template. Web tools such as Cold Fusion and Java Server Pages have long provided a simple way to mix data with HTML in templates.
Swift offers a sleek templating system with an escaped open parentheses, followed by the expression to evaluate, followed by a closed parentheses. Three extra characters may be the smallest number of keystrokes needed to offer this functionality.
What's with all the semicolon hate? They're just a simple way for designating the end of a programming statement, but somehow a growing number of developers can't be bothered to type them.
Protocols (aka interfaces) -- from Java and C#
When programmers create elaborate object-oriented class structures in Java and C#, they often begin with an interface at the foundation. The interface is a basic class that defines the structure for all of the functions that the classes must offer if they want to fit the definition. Swift uses the term "protocol" for sketching out a blueprint for a collection of classes.
Tuples -- from Lisp and Python
Sometimes a method needs to return more than one value. Early languages like Lisp assumed that everything was a list or a tuple, and more modern languages like Python offer explicit syntax for matching up the N value returned from a method with the N variables that will be bound to them. Swift follows in this tradition.
Automatic reference (akin to garbage collection) -- from Java, C#, and (gasp) Objective-C
Early reports suggested that Swift was sporting garbage collection, those automatic routines that sweep through memory reclaiming bytes no longer in use. Java and C# programmers love garbage collection, at least until it causes their machine to freeze up for a second. Swift uses automatic reference counting, a similar solution that's been popular with Objective-C users. In this case, the acorn didn't fall far from the tree.
Signed and unsigned integers -- C# and Objective-C
Good system program often means working at the byte level. While some abstract languages, such as Java, have avoided the complexity of unsigned integers, other languages, such as C#, have embraced them. Swift offers signed and unsigned integers of one, two, four, and eight bytes -- just like Objective-C and all the better to hack.
Emerging Leaders 2020
ARN Innovation Awards