Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the best-selling Take Control ebooks.

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.


TextExpander: Your knowledge at your fingertips. From email to code,
gather your text "snippets" for reuse, each only a keystroke away.
Get consistency and accuracy everywhere you type! Share with your
team on Mac, iPhone, iPad, Windows (beta). <>

Comments about Swift: Who Is Apple’s New Programming Language For?
(Comments are closed.)

Jim Stead  2014-06-12 09:48
Apple's simple motive is to improve the quality of apps, and swift is part of the equation. Developers will adoppt it swiftly, since Apple will make tools like playground that will only work in swift. They are not making some visual basic here.
David Emery  2014-06-12 11:13
I'm disappointed in Swift. I would have preferred a much more ambitious language that goes A Lot farther in precision and techniques to prevent bugs, security faults, etc. In particular, I think keeping with C syntax perpetuates bad language design from the early 1970s. Pascal, Ada or Eiffel would have been a much better, more readable and more precise starting point.
David Weintraub  2014-06-12 11:27
I am not a Objective-C programmer. I know a few languages, but I am not a professional programmer, and I found Objective-C somewhat opaque.

Objective-C is older than C++ and depended upon macros to decode it into a C program. This is why its syntax is so clumsy. Those square brackets were there to help the compiler to look for certain features.

Swift syntax is cleaner and easier to understand than Objective-C. The compiler catches more issues. You have less coding problems. It is definite that Swift will replace Objective-C and most programmers tell me there will be little love loss.

However, the basic programming syntax isn't how you program. I picked up the basic Java syntax in a few weeks. C# was designed to allow Windows C++ developers to move easily into the .NET framework. Syntax isn't the issue.

The big barrier in modern programming is the FRAMEWORK. You don't merely write programs, you use the framework to build your program.

I'll have to see if Swift makes using the iOS framework easier. The framework is the key reason why Apple didn't use something like Python or Java as a starting point.
Michael E. Cohen  An apple icon for a TidBITS Staffer 2014-06-12 11:36
At first glance, it *may* make using the frameworks easier. In Xcode 6, every call has both an Objective-C and Swift version in place, so you don't totally have to ”think” in Objective-C when calling the frameworks in Swift.

More helpful, though, are the Playgrounds, where you can fiddle around with the frameworks in real time, seeing how a call works, without needing a whole compile-run-debug cycle.
manuel bendala  2014-06-12 15:02
As you, I'm not a professional programmer. I have never written a line in Objetive-C. But I do program a lot, mainly in Mathematica: an interpreted language with thousands of frameworks. HyperTalk... I miss it. Processing is interesting, too... you write Java methods without knowing it... (¿PlayGround?) Sage is a lot of frameworks glued with Phyton code...

We could read again the Alan Kay's text (DynaBook). Well, the thing is that we need lots of programming languages. Without ; , please.
Philip Machanick  2014-06-12 13:38
I hope they release it outside the Apple ecosystem. I do coding for many reasons unrelated to Mac or iOS apps, and can’t justify putting time into a language only good for one platform. Maybe different if you are trying to sell to the mass market but I don’t have that problem.

That said, I’ve been paging through the docs and it does look quite interesting, with syntax cues from a lot of sources – even Pascal-like notation for declaring variables.
Charlie Hartley  2014-06-12 17:49
Hmmm... I'm what you might call a dabbler. I gave up real programming when I left my Apple IIe behind along with BASIC and Assembly Language, but I've frequently messed around with javascript and php for web pages, and done a fair amount of scripting for FileMakerPro. I'm really tempted to investigate Swift, but I'm wondering just what I might use it for.
Michael E. Cohen  An apple icon for a TidBITS Staffer 2014-06-12 19:24
Right now Swift is more or less an alternative language that you can use in place Objective-C. So, you can use it for most of the stuff in Xcode that you would otherwise have had to use Objective-C to make: primarily iOS and Mac apps, but also other things that use the Cocoa or Cocoa Touch frameworks.

Keep in mind that it's early days in the life of Swift; other uses are sure to arise over time as more developers use it and as Apple extends its capabilities.

If you come from a scripting background with languages like php or JavaScript, Swift might provide any easier entry point than Objective-C for you to begin to learn something about object-oriented programming. Or not: some find Objective-C pellucid, while others find it confusing in that regard.

In any case, the _Swift Programming Language_ guide is a free download from the iBooks Store, so it costs you nothing to check it out (hint: skip the book's opening section, Welcome to Swift, which is designed to help Objective-C developers get a handle on Swift, and turn instead to the section that follows it, Language Guide).
Mike Brown  2014-06-13 10:07
I actually learned how to program on my HP25 calculator. After a weekend of pouring over the books I was writing programs! When I learned BASIC, I found it to be so similar that I was able to apply what I had already learned and computer programing was easy. Later as a teacher, I found that my students were no longer learning how to program at all. Their HP calculators had gotten so complicated that it was harder to write even simple programs. Of course everyone now had access to real computers and the need was no longer there.

I’m not a professional programer but I have made various programs for myself through the years in a number of languages. For me C, C++, and especially Obj-C were the most difficult family of languages. So I like Swift.

But to me even Obj-C and object-oriented programming was not my real problem. Languages only have so many different kinds of statements. But the framework is like trying to learn a spoken language with 5000 or more different letters!
Mike Brown  2014-06-13 10:12
I’m not saying to do away with the framework. The framework is the price we pay in having all our programs work along certain guidelines. I’m not saying we should do away with that. It obviously fits in with having a safe system etc. We also appreciate the uniform way all the programs work. They follow set guidelines.

But at the same time it has virtually closed the door to dablers in programing their own macs.
Greg Saddler  2014-06-16 13:58
Judging from the article,... Dabblers more than likely, are planned for Swift 2.0
zaheer  2014-06-13 18:35
To learn Swift Definitely check out
Mike Brown  2014-06-15 19:06
Christopher R Rosien  2014-06-16 22:47
Gosh I was hoping for a 4GL solution like LiveCode! I want languages that let me bang out apps quickly using simple english like code. My BASIC, MC68K assembly, Pascal, C, C++ days are long behind me!
Harmon Abrahamson  2014-06-17 08:52
Pascal and FORTRAN were my go-to languages, but I haven't done serious programming since my main machine was a Duo. (Remember those?) I avoided learning C and its brethren; maybe Swift will get me back in the traces again...
Swift Programming Language Guide for Android users
Michael E. Cohen  An apple icon for a TidBITS Staffer 2014-06-18 07:59
Of course, Swift doesn't run on Android platforms, and, more importantly, the publication of the book on Google Play violates Apple's copyright (just because a book is free doesn't mean it isn't protected by copyright law).
iGerbil  2014-06-22 19:10
Just found a nice Swift training, it gives you a feeling what it's all about....
Walter Johnson  2014-06-23 09:11
This is the second time Apple has rolled it's own language to target only it's own hardware devices. The Newton was programmed in NewtonScript.
Paul Conning  2014-07-01 04:28
New training corse for learning Swift. From the language basics to development of complete apps for iOS and Mac OS