
One of the biggest announcements coming out of WWDC this year is the creation of a completely new programming language called Swift – the newest programming language used to build apps. Today, most all Apple software is built with Objective-C. Originally designed in the 1980s and soon adopted by Next Computer–the Steve Jobs-led company whose technologies eventually morphed into the modern Mac and the iPhone–the language has ridden these devices to enormous popularity.Apple is wasting no time getting developers educated on the new tools available to them by making The Swift Programming Language guide book immediately available on iTunes. Apple’s new guide offers 500 pages of info on Swift, providing readers with a tour of the new language, along with a detailed guide that dives into each new language feature.
It should feel familiar to those who are already used to Objective-C, Apple says, and is meant to “unify the procedural and object-oriented portions of the language.” It does diverge from Objective-C in more than just the syntax, though; it also features variable types like tuples and optional types. It also includes operators that aren’t found in Objective-C, which allow you to perform remainder operations on floating-point numbers, for example.
Here are some of the highlights of the language according to Apple:
- Closures (similar to blocks in C and Objective-C) unified with function pointers
- Tuples and multiple return values
- Generics
- Fast and concise iteration over a range or collection
- Structs that support methods, extensions, protocols.
- Functional programming patterns, e.g.: map and filter
Objective-C was always a hard language to pick up for new developers. We’ll have to see if Swift makes getting started with app development on Apple’s platforms easier, but from a first look at the documentation, it definitely feels more accessible than Objective-C.
Interactive Playground
On top of this, Apple has added the “interactive playground”, a way of viewing the results of a piece of code as you type it. It reminds me of the Javascript language, trying to make it a more visual endeavor. It’s absolutely amazing. This is the wild card. Depending how well it works, the playground could push mainstream programming in a new direction, providing a more intuitive means of building code. This isn’t necessarily an Apple invention, but it is something that has been bubbling up over the last few years.
But if you put the playground to one side, Swift isn’t really that different from many other languages. It’s mainly a way of bringing Apple’s platform up to par with languages like Ruby and Python–all without sacrificing the speed of Objective-C.
Get Started
Ready to begin? Start with downloading the new XCode 6 Beta from the Apple Developer Portal. Next start reading The Swift Tour and for the best experience open the Guided Tour right in playground, which allows you to edit the code listings and see the results immediately.