Unwrapping Swift

Unwrapping Swift

Developers have had plenty to say about Swift since its announcement at this year's Worldwide Developers Conference. It sure seems like only a matter of time before it supplants Objective-C as the programming language of choice on (at least?) Apple platforms.

But the far-reaching legacy of Swift may be its departure from customary object-oriented paradigms. It borrows adapted let expressions and other functional language grammar by way of static code analysis, and (at least in theory) supports rich interactive editing inspired by projects like Light Table and this talk by Bret Victor. It's refreshing to see capabilities like these in a language with serious platform support, and bodes well for hopes of better (more collaborative?) developer tools. So while a lot of analyses have focused on performance and compatibility, I want to consider Swift's potential impact on the practice of software development.

"Easy Is Complex, Simple Is Hard"

A lot of the criticisms of Swift I've seen so far are basically complaints about missing features—dynamic typing and introspection are limited, initializer logic can't be freely subverted, singletons are not encouraged, and so on. While I understand it can be hard to adjust, there's a bigger picture here. Programming languages can help developers write better code through both the inclusion and exclusion of features. If you value pragmatism, a language that makes it easy to follow effective design patterns and hard to follow poor ones is better than a language that makes it equally easy to follow both.

The Swift team has an advantage here just by starting fresh. New features can be grafted onto an established language, but it's difficult to remove anything that a lot of legacy code depends on. As features accumulate, even if they're useful, the language as a whole loses consistency and focus (C++ epitomizes this tendency). In a way, good programming languages can't please everyone—not if simplicity is valued at more than a surface level.

Education

An unfocused language is also harder to learn. Chris Lattner, who spearheaded Swift's development, has mentioned that his team intends for it to be "a great teachable language". Rather than requiring a large amount of domain knowledge upfront like C++ or Java, most of Swift's syntax is designed to be learnable incrementally, along the lines of scripting languages like Python. This becomes important when paired with interactive editing, because it really affects being able to learn through experimentation. Having gotten my start with tools like ProjectFUN and GameMaker as a kid, I can vouch for the value of simple trial and error.

In the meantime, Swift is still an interesting and fun language to play around with—and the foundations are in place for some promising future developments.

  • © 2014 Erik Foss