Feeds

Apple: We'll tailor Swift to be a fast new programming language

Kiss goodbye to five years of Objective-C

Providing a secure and efficient Helpdesk

WWDC Apple stunned the audience at its Worldwide Developers Conference in San Francisco on Monday with a tool few expected: a new programming language for iOS and OS X software called Swift.

There already is a programming language called Swift that was developed by the University of Chicago and Argonne National Laboratory for use in parallel computing applications. This isn't that.

What it is, is an entirely new syntax that – in the words of Apple senior VP Craig Federighi, who unveiled it during the Monday morning WWDC keynote – aims to be "Objective-C without the baggage of C."

Some of that "baggage" will already be familiar to developers who cut their teeth on C but later moved on to scripting languages such as Python (and Federighi compared Swift to Python several times during his presentation).

Like scripting languages but unlike C, Swift lets you get straight to the point. The single line println("Hello, world") is a complete program in Swift. Note, also, that you don't even have to end the statement with a semicolon, as you do in C. Those are optional, unless you're combining multiple statements on a single line.

Swift also aims for a level of scripting language–like interactivity. At WWDC, Apple developer-tools chief Chris Lattner demoed coding using a feature called "playgrounds," which allow a developer to modify portions of a program in Xcode and see the results in an output window in real time.

Craig Federighi introducing Swift at WWDC

Swift code outperforms Python by a wide margin, Federighi said, and even beats Objective-C

Unlike scripting languages, however, Swift is compiled, using a compiler based on the LLVM project (which Lattner created before joining Apple in 2005). That means programs written in it are fast. Compared to Python, Federighi said, a complex object sort written in Swift ran 3.9 times faster, and RC4 encryption ran 220 times faster. In fact, he said, the Swift code even ran faster than the same algorithms implemented in Objective-C.

Familiar, yet new

Swift is object-oriented, but it also supports some functional programming styles. Functions can be passed around as data, for example, and the language also supports closures.

It also adopts a number of modern language features, such as optional typing, generics, type inference, namespaces, and tuples as a data type. Identifiers can be composed of any Unicode characters – so you can name your variables in Chinese, for example, or even use symbols.

Swift has also been designed to make it easier for developers to write secure code. Federighi said the language's syntax "defines away large classes of common programming errors; they're just not possible."

According to Apple's developer documentation, Cupertino spent years developing Swift as a 21st-century language that's suitable for everything from short programs to entire operating systems.

"Swift combines the best in modern language thinking with wisdom from the wider Apple engineering culture," the manual not-so-humbly states. "The compiler is optimized for performance, and the language is optimized for development, without compromising on either."

At the same time, Swift is designed to be fully interoperable with Objective-C. Objective-C APIs can be called from within Swift code and vice versa. Code written in both languages can be mixed and matched within the same program, and migrating code from one language to the other should be easy.

That in turn means Swift already supports Apple's key development frameworks, including Cocoa and Cocoa Touch.

What you shouldn't expect from Swift, however, is a general-purpose programming language for use outside Apple's ecosystem. The fruity firm made no mention on Monday of how it plans to license Swift, whether it will release the source code to its compiler, or whether it will be possible to write code in Swift for platforms other than iOS and OS X – but we think maybe you shouldn't hold your breath for any of that.

In addition to its online documentation, Apple has released an e-book, The Swift Programming Language, that's a free download from the iBooks Store.

To start working with the language itself, you'll need to download the beta release of XCode 6, which includes tutorials to get you going. ®

Internet Security Threat Report 2014

More from The Register

next story
Microsoft on the Threshold of a new name for Windows next week
Rebranded OS reportedly set to be flung open by Redmond
'In... 15 feet... you will be HIT BY A TRAIN' Google patents the SPLAT-NAV
Alert system tips oblivious phone junkies to oncoming traffic
Apple: SO sorry for the iOS 8.0.1 UPDATE BUNGLE HORROR
Apple kills 'upgrade'. Hey, Microsoft. You sure you want to be like these guys?
SMASH the Bash bug! Red Hat, Apple scramble for patch batches
'Applying multiple security updates is extremely difficult'
'Google is NOT the gatekeeper to the web, as some claim'
Plus: 'Pretty sure iOS 8.0.2 will just turn the iPhone into a fax machine'
ARM gives Internet of Things a piece of its mind – the Cortex-M7
32-bit core packs some DSP for VIP IoT CPU LOL
'People have forgotten just how late the first iPhone arrived ...'
Plus: 'Google's IDEALISM is an injudicious justification for inappropriate biz practices'
prev story

Whitepapers

Providing a secure and efficient Helpdesk
A single remote control platform for user support is be key to providing an efficient helpdesk. Retain full control over the way in which screen and keystroke data is transmitted.
Intelligent flash storage arrays
Tegile Intelligent Storage Arrays with IntelliFlash helps IT boost storage utilization and effciency while delivering unmatched storage savings and performance.
Beginner's guide to SSL certificates
De-mystify the technology involved and give you the information you need to make the best decision when considering your online security options.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.
Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.