At the Worldwide Developers Conference (WWDC) in June, Apple surprised many developers when it announced Swift, a new programming language for iOS and OS X. For the past several months, more developers have been using Swift side-by-side with Objective-C, Cocoa, and Cocoa Touch to build apps, giving them a chance to see what Apple believes will serve as its future framework for all software produced by third-party developers.
The big question on the minds of many in the industry, however, is what makes Swift so special. What will allow it to replace the standard languages already in use for iOS and OS X?
Read on for the answers:
1. It’s Adaptable to Its Respective Environment
One of the nice things about Apple developing Swift is that the company was able to make the programming language work across both iOS and OS X. That means developers will have no trouble quickly porting their apps back and forth; it could also mean that many more apps will work cross-platform, since Apple’s own vision is to maximize the number of programs available to its products.
Perhaps of greater importance to the average developer, Swift works alongside Objective-C. So while developers could create apps that are entirely written through Swift, code from its programming language can also be integrated into Objective-C-based apps and still work perfectly fine.
Rather than compete with the likes of Objective-C, Apple has found a way to play nice while still enticing developers to make the switch. It’s a smart move that could pay off in dividends down the road.
2. Apps Run Fast (or So Apple Says)
Both developers and Apple have said that Swift is lightweight and allows for apps to run fast without any major slowdown. The key is Apple’s use of the LLVM compiler, which quickly converts to native code on Apple hardware; Apple’s handling of syntax errors and low-level primitives also helps to move things along.
So far, Swift code hasn’t been benchmarked, but those who’ve used it—including yours truly—have found that it does address some of the issues found in standard Objective-C, and it makes both writing code and executing programs much quicker.
Still, it’s hard to please developers, who are always seeking the next best thing and ways to maximize the efficiency of their apps. Apple cannot simply rest on its laurels and expect everything to stay fine: Swift must be continuously updated and improved, or it won’t stand a chance at truly appealing to the vast majority of developers.
3. Notorious Errors Have Been Addressed
Let’s face it: While Objective-C works well in its own right, it’s by no means perfect. There are several quirks to the code that make it somewhat annoying to use at times, and it comes with some errors that make writing apps a frustrating process.
For instance, Apple makes clear that Swift will not, by default, expose pointers, leaving out much of the marking that goes into building code. The company’s platform also ditches the “break” command and array bounds are always checked. Programmers can even allow overflow using several operators—a major improvement over Objective-C.
One other small but important improvement: As developers write code in Swift, the result is immediately shown in a “playground.” The underlying idea is that developers can find their errors early and fix them, streamlining the process for building an app that works perfectly.
So, what’s the verdict on Swift? It’s hard to tell from this vantage point. The programming language is in its infancy and developers still haven’t picked it up to a degree that it’s a new standard. But so far, Swift is delivering a solid experience that should appeal to the average developer looking to bring apps to Apple-based products.
In other words, it’s at least worth checking out if you’re an Apple developer.
- How to Build Apps in Swift
- Building Apps in Swift: Using Storyboards