Skip to content
Thoughtful, detailed coverage of everything Apple for 33 years
and the TidBITS Content Network for Apple professionals
20 comments

Swift: Who Is Apple’s New Programming Language For?

As we noted at the end of our recent Worldwide Developer Conference overview article (“Apple Unveils iOS 8 and OS X Yosemite at WWDC,” 2 June 2014), Apple has released a brand new programming language: Swift. Of all the speculation about what Apple would announce at WWDC, no one expected a new programming language.

The developers in the keynote audience reacted to Swift’s unveiling with surprise and delight, and response since then has been largely, if not unreservedly, positive. One developer has pointed out to us that the most positive comments that he’s seen tend to come from programmers who are active users of Objective-C, currently the programming language of choice for apps on Apple’s platforms; those less steeped in Objective-C development projects are somewhat more skeptical.

So, a new programming language. Those tend to pop up like mushrooms on a dewy morning. Why should you care?

Honestly, unless you like to dabble in programming (and by “programming” I mean anything from tinkering with macros in a spreadsheet to full-on application development), you don’t need to care. Not that Swift won’t have an impact on how you work and play with your Mac, but Swift’s impact will be subtle and gradual, and its nature will depend on how many developers adopt Swift and what they develop when they do adopt it.

One of the objections tossed out by those who are skeptical of the need for Yet Another Language is that there are lots of languages already around that Apple could have adopted instead of rolling its own. However, all the proposed candidates are ecosystem-agnostic programming languages, designed to develop software for a wide range of computing platforms, generally without full-fledged native interfaces.

That’s not what Apple wanted. It wanted a language optimized to create software for its platforms; that is, Apple devices, such as the Mac, the iPhone, the iPad, and likely even the Apple TV.

Apple has ridden in the language development rodeo before: it adapted several versions of Pascal for the Apple II and early versions of the Mac that were customized for building Apple II and Mac programs. It collaborated with IBM, co-developer of the PowerPC chip that powered Macs at the time, to develop ScriptX, a cross-platform object-oriented programming language for multimedia. It developed scripting languages like HyperTalk and AppleScript, so non-professionals could develop Mac apps and automate tasks on the Mac. And, when Apple bought NeXT, it took over the development and customization of Objective-C, which came along with the NeXT purchase, making the language the standard for programs on the Mac, and, later, on iOS. So developing programming languages that target Apple products is a part of Apple’s DNA.

That said, to gain wide adoption, Swift must overcome three challenges:

  • It must be easy to learn, or nobody will bother to learn it.

  • It must make programming for the Mac and iOS easier and more efficient when compared to the programming experience with Objective-C.

  • It must be able to produce the same kinds of programs as Objective-C, with similar (or better) performance than Objective-C can produce, or current developers won’t look at it.

An initial look at Swift suggests that it can meet these challenges.

First, Swift looks easy to learn — at least, it looks that way to me (full disclosure: I’ve learned and worked with lots of programming languages over the decades — this isn’t my first rodeo either). If you know a little C or Java or even (are there any of you left out there?) Pascal, the language will look familiar. Moreover, Swift manages to add in some sophisticated programming language features (closures, tuples, and variadic parameters, to name just a few geeky examples) without making the language syntax that expresses them cumbersome or opaque.

Second, the compiler for the Swift language (the program that turns the Swift code that developers write into a running program) is designed to catch some common programming errors that the Objective-C compiler can’t, making programmers more efficient: it’s easier and faster to catch a bug early on, when a program is being compiled, than later when it causes the running program to crash or misbehave. Add in a new cool programming tool, Playgrounds, with which programmers can try out samples of code and see the results in real time, without having to do any compiling at all, and coding becomes fun again.

Third, Swift has been designed to use the same runtime system that Objective-C uses (the “runtime” is the low-level software that supports Mac and iOS programs written in Objective-C), so it is compatible in that regard. In addition, Swift can access all of the code frameworks that Objective-C programs employ, so just about any Mac or iOS feature that an Objective-C program can use, a Swift program can. Moreover, Swift has been tailored to do some operations faster than equivalent Objective-C programs; it may well be that some Swift programs will not only match the performance of equivalent Objective-C programs, but might even be a little snappier. And, in those cases where Objective-C remains faster or better suited to a particular
task, no problem: Swift code and Objective-C code can coexist quite happily in the same program.

So much for current OS X and iOS developers: Swift already seems to be winning a sufficient number of hearts and minds in that community to become a success.

But what about the dabblers, the hobbyists, and the kids who think it would be cool to write their very own apps? Does Swift offer easy entry into programming the Mac like HyperCard did, or into automating the Mac like AppleScript does? Is there anything about Swift that might win their hearts and minds too?

That’s tougher to answer. My guess is that it may, eventually. Right now, that is not Apple’s primary goal for Swift; providing an alternative to Objective-C and meeting the needs of its current developers is.

What’s still in short supply is sample code, the projects that come with Xcode to show programmers new to the Mac or iOS how to do basic stuff. Those who want to soar on Swift’s wings may have trouble getting airborne without some real-world Swift examples to follow. Right now, all of the sample code I saw in the Xcode 6 beta is still in Objective-C; the few examples that exist require a trip to the Apple Developer site or a Web search. Even the new Playgrounds that come with Xcode 6, which are loads of fun and very instructive, are devoid of any built-in examples; you have to look to the Web for those, too.

That said, the clarity of the language itself, and its integration with Apple’s code frameworks, should make it easy for tech publishers and teachers to develop Swift training materials for amateurs, hobbyists, and students. Swift code is already beginning to appear outside of Apple’s own garden. Nor is Apple standing still in providing its own training materials, offering not just one but two free Swift books in the iBooks Store. And it’s even conceivable that Xcode’s Playgrounds could someday
evolve into an application development environment for “the rest of us,” similar to what RunRev provides with its HyperTalk-inspired LiveCode.

On June 1st, nobody outside of Apple had heard of Swift. Twenty-four hours later, tens of thousands of developers were buzzing about what they planned to do with it.

Change comes swiftly these days.

Subscribe today so you don’t miss any TidBITS articles!

Every week you’ll get tech tips, in-depth reviews, and insightful news analysis for discerning Apple users. For over 33 years, we’ve published professional, member-supported tech journalism that makes you smarter.

Registration confirmation will be emailed to you.

This site is protected by reCAPTCHA. The Google Privacy Policy and Terms of Service apply.

Comments About Swift: Who Is Apple’s New Programming Language For?