WatersWorks

Blog archive

Apple's Swift: Objective-C Without the Bad Stuff

The amount of both mainstream and tech press generated by Apple's annual World Wide Developer Conference, winding down in San Francisco today, always catches me by surprise. It shouldn't, I suppose, but everyone covers this show. I agree with the argument that Apple has earned the attention with its bleeding-edge, category-creating, market-overhauling innovations over the past couple of decades, but it's still true that somewhere around 90 percent of all PCs worldwide are running Windows. Maybe I should look at the coverage of the WWDC as further evidence of the receding relevance of the PC as a personal computing platform.

Among the many announcements at this year's show (covered thoroughly by my colleague David Ramel here), Apple CEO Tim Cook called out the new software development kit (SDK) as "the biggest release since the launch of the App Store." The new SDK comes with more than 4,000 new APIs, and a feature called "Extensibility," through which devs will be able to extend services to other applications via the App Store.

But for my money, the official introduction of the successor to Apple's Objective-C programming language was the biggest news for developers this year. Dubbed "Swift," the new language sheds the "baggage of Objective-C" to provide "an innovative new way of coding for Cocoa and Cocoa Touch," as the Web site puts it. Where Objective-C relied on defined pointers, the Swift compiler infers the variable type. But it keeps such features as well-defined namespaces, generics, and operator overloading.

Apple says the new language will be able to co-exist alongside existing Objective-C files in the same project. Swift is ready for developers now who want to kick the tires, and it will be supported with the next version of the Xcode IDE (now in beta). When OS X Yosemite and iOS 8 are released later this year, developers will be able to submit Swift-based applications to the App Store.

I'm calling this the official introduction because Swift has reportedly been in development for four years. Chris Lattner, director of Apple's Developer Tools Department, says on his personal blog that he implemented the basic language structure in 2010 off the radar. Contributions from others started coming "in earnest" in late 2011, he writes, and the language finally became a "major focus" for his tools group last year.

"The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas," Lattner writes. "Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list."

Of course, Swift isn't the only new (ish) addition to the programming language landscape. Under the category of emerging languages, there's Google's open-source Go and Dart; Red Hat's Ceylon; Opa; and Typesafe's open source Scala.

In fact, IDC analyst Al Hilwa believes we're living in "a golden age of programming languages."

"Computer scientists never tire of creating new languages, and this is illustrated by Apple's latest creation called Swift," Hilwa told me in an email. "There have not been too many examples of single-vendor-promoted languages achieving wide adoption. Most of the popular programming languages that have come to wide-spread use, like COBOL, FORTRAN, C, and Java, have had multi-vendor support. Objective-C was catapulted into fame by the unique disruption of Apple's iPhone, and C# was promoted by Microsoft during its pinnacle of dominance as the language for Windows apps."

Initial reactions to the language seem to suggest a promising future for Swift. As one breathless coder told me, "It's Objective-C with all the bad stuff scraped out." But Hilwa argues that the success of the language will depend largely on how hard Apple promotes it, and how well that promotion is received by the Apple appdev ecosystem.

"It helps Swift that it was designed for ease of learning, that it produces fast code, and that Apple will integrate it deeply with its tools," he said. "But, having looked at it briefly, I can say that despite its many great features, it has a 'best-of' flavor that combines many great ideas surfaced in other successful languages, like Java, JavaScript, and C#. This typically means it has a complexity that may make it easy to learn but hard to master. Still, if a single vendor can generate wide adoption of a programming language today, it is Apple, as it sits at the pinnacle of its platform dominance."

Posted by John K. Waters on June 6, 2014