Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

10 things you should know about Apple's Swift

Paul Rubens | July 22, 2014
Apple recently unveiled Swift, a new language to replace Objective-C for OS X and iOS application development. Apple won't accept submissions built using Swift to the iOS or Mac App Store until the fall, when iOS 8 and the next version of OS X (Yosemite) ship, so there's still some time to learn the ins and outs of this new programming language.

Apple recently unveiled Swift, a new language to replace Objective-C for OS X and iOS application development. Apple won't accept submissions built using Swift to the iOS or Mac App Store until the fall, when iOS 8 and the next version of OS X (Yosemite) ship, so there's still some time to learn the ins and outs of this new programming language.

Without further ado, here are 10 things you need to know about Swift.

Swift should appeal to younger programmers. Swift is more similar to languages such as Ruby and Python than is Objective-C. For example, it's not necessary to end statements with a semicolon in Swift, just like in Python. In Objective-C, on the other hand, it's necessary to do so; forgetting a semicolon at the end of just a single statement can cause errors. If you cut your programming teeth on Ruby and Python, Swift should appeal to you.

That said, Swift is compatible with existing Objective-C libraries. There's no problem with writing new modules in Swift that interoperate with existing Objective-C code bases. That may make Swift attractive if you've already built a considerable skill base in Objective-C, too.

Swift should be a safe(r) language. Apple has made an effort to make Swift safe in a variety of subtle ways. For starters, programmers must include brace brackets to open and close "If" statements, which prevents bugs such as the SSL "goto fail" error. In addition, switch statements must include a default statement. This guarantees that something will run at the end of the statement even if none of the possibilities in the statement are satisfied.

Swift isn't that fast. Despite the name, Swift is unlikely to result in applications that run much faster than applications written in Objective-C. Although the two languages are different, they're not that different both target the same Cocoa and Cocoa Touch APIs (for OS X and iOS, respectively), both are statically typed languages and both use the same LLVM compiler as well. There will inevitably be performance differences, as the two languages aren't identical after all, but don't expect significant differences.

Swift is incomplete. The language that's available today isn't the finished product. Apple is still working on it, and it's highly likely that new features will be added over the coming months. While it may well be worth coding in Swift to familiarize yourself with the language, to do so you'll need to use Xcode 6 beta and the iOS 8 SDK (also in beta). And don't forget: Apple's app stores won't accept apps built with Swift until it first releases Yosemite and iOS 8.

 

1  2  Next Page 

Sign up for CIO Asia eNewsletters.