Swift: Apple's next-generation programming language 4 years in the making

Swift, Apple's new programming language billed as taking the C out of Objective-C, was one of the biggest surprises at WWDC 2014. The Swift project started at Apple roughly 4 years ago as one of several explorations into what would replace the NeXT-era Objective-C language. It was spearheaded by Chris Lattner, head of Apple's developer tools department, who also spearheaded LLVM (lower level virtual machine) and Clang, Apple's compiler technologies. Lattner shared some insight into Swift on his site, nondot:

I started work on the Swift Programming Language (wikipedia) in July of 2010. I implemented much of the basic language structure, with only a few people knowing of its existence. A few other (amazing) people started contributing in earnest late in 2011, and it became a major focus for the Apple Developer Tools group in July 2013.

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. 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.

That Swift won out over existing higher level and scripting language projects is provocative, but it's also early days. Lattner is the only one who has been using Swift since its inception and few even inside Apple, until Monday morning, even knew of its existence.

There's no word on how much, if any, of Swift will be open sourced, for example. Right now Lattner and team are focused exclusively on getting the final release ready for the fall. Swift has also only just been introduced and thousands if not millions of people will soon be hitting it full speed and full force. They'll find edge cases and do things no internal planning or QA (quality assurance) could ever prepare for or expect. Apple will watch, learn, and Swift will change and evolve.

So will the rest of Apple's platforms. Objective-C was the result of Apple buying NeXT. Swift is the result of steady, continuous evolution. It's the result of smart management and responsible stewardship, that, in the fullness of time, will likely result in just as much of a leap forward as a NeXT-style purchase. It's also something more.

In his brief write up Lattner also discusses Playgrounds, the interactive development environment in Xcode. The Web inspector provides immediate feedback for HTML5 and has been a huge boon for web developers. Lattner hopes that, with Playgrounds in Swift, Apple won't just be making programming better but will be making it more fun and accessible to the next generation of programmers. That's an incredibly important and laudable goal.

If there's one thing I've heard repeatedly from developers since Swift's unveiling it's exactly that hope. My generation grew up with Basic and Logo and other languages that made it relatively easy to get programming into elementary schools and kids into programming even at a very young age.

Objective-C was unlikely to be in any grade school curriculum, unlikely to be any child's first programming language. We'll have to wait and see how Swift and Playgrounds fare, but if they really do make it easier to engage new programmers at a younger age the value to Apple, the industry, and the future will be incalculable.

Poetically, the WWDC 2014 app crafted by the evangelism team is the first public Swift app to be released. Millions more will follow.

Apple has made the Swift Programming Language Guide available in the iBook Store. Anyone not already a seasoned Objective C programmer thinking of giving it a shot?

Rene Ritchie

Editor-in-Chief of iMore, co-host of Iterate, Debug, Review, The TV Show, Vector, ZEN & TECH, and MacBreak Weekly podcasts. Cook, grappler, photon wrangler. Follow him on Twitter and Google+.

More Posts

 

22
loading...
93
loading...
138
loading...
0
loading...

← Previously

What are you most excited about in iOS 8?

Next up →

WWDC 2014 keynote now available through iTunes and YouTube

There are 18 comments. Add yours.

TimRoesner says:

It makes programming way easier. It is complex but at the same time simple. First I wanted to really dive into objective-c but now swift seems like the obvious choice for new apps

Sent from the iMore App

dalyapp says:

Agreed. I know C/Java and was thinking of learning Objective C. Now I'll dive into Swift instead. Looks like a great language.

Sent from the iMore App

ZiggyMo says:

For anyone interested in learning Swift, there's a lot of great tutorials / code samples / guides at:

http://www.LearnSwift.tips

Ashish Asawa says:

Looks good so far in surface, have to see how it connects with cocoa and existing code base. So far I see inspiration from python (which is good).

invalidname says:

It's pretty much a one-to-one correspondence from Obj-C to Swift classes and method calls. For example, here's a couple lines I ported yesterday:

// Objective-C
SLComposeViewController *tweetVC =
[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter];
[tweetVC setInitialText: @"I'm tweeting in Obj-C"];

// Swift
let tweetVC =
SLComposeViewController (forServiceType: SLServiceTypeTwitter)
tweetVC.setInitialText("I'm tweeting in Swift")

You can see the classes (SLComposeViewController) and methods (setInitialText) line up pretty cleanly; for simple stuff like this it's just a matter of moving the syntax around.

The Reptile says:

Count me in as a non-programmer who will at least kick the tires. I've taken intro classes in Java (not for me) and Python (more for work than hacking) but have not really used it because the programs would not have been used much. Learning Swift seems as easy as Python to learn and the results could really be fun for me and my kids. I already have the documentation and look forward to downloading the development tools.

Lt_Solorna says:

I will look into this as well.

33497746 says:

I just started to learn Objetive C, and now Will change to Swift, read that is simpler to learn and program..

Posted via iMore App

Nathan Bael says:

I am considering it. The apps I want to make though aren't all that complicated. Mostly I want to make interactive books and learning programs.

parishyoung says:

I got lost in the first 10 pages.

Sent from the iMore App

Velvet_Pelvis says:

Lol. Same here. I know absolutely zero about programming/coding but really would love to learn. It seems as if putting my energy into Swift is the best way to go. I hope someone writes a tutorial for complete beginners some time soon.

Sent from the iMore App

Dev from tipb says:

My daughter loves her iPad and wanted to learn programming, but after going through Objective C Karel the Robot, I quickly ran out of interesting-for-a-kid-but-still-good-learning ideas. Swift and its playground look very interesting for this.

Sent from the iMore App

Wpcrumbley says:

I'm not a developer so I'm sorry for my ignorants. Can swift be used to write android apps? If not will this be a game changer as far as people moving away from android apps?

Dev from tipb says:

At present, Swift is Apple-only. As for whether it will be a game changer...that depends on what developers actually do with it. No end user ever has cared if a program was written in C or Ruby or Lisp - they cared if the program did what they needed, and did it well. If Swift enables developers to make better apps or encourages a slew of Apple only apps, it might make a difference. Otherwise, no.

Sent from the iMore App

eshy says:

What Apple should have done is release a CTP two years ago to start getting feedback from the developers who would actually use Swift to build apps.

I've been saying they should move on from Objective-C but they won't because it's another lock-in, so it's not that surprising that in moving on they're moving to another propriety language.
If they really wanted to be a good player in the dev universe they would have at least used the same syntax as the more popular languages.

And of course, they waited until I release an app written in objective-c and feel like that language is no longer an issue before releasing this new language...

Rene Ritchie says:

Updated to clarify the web inspector comparison, and to add the WWDC 2014 app.

ralphtweety says:

Not a coder, but this looks very cool anyway.