Advertisement

Swiftly moving forward

Apple’s new programming language enables faster, easier development of iOSX apps

At Apple’s World Wide Developers Conference 2014, Apple unveiled a new programming language, “Swift,” which will soon replace Objective-C as the main language used by iOSX developers to create apps. Aptly named, Swift is purportedly much faster than other languages. For example, a complex object sort algorithm will run 3.9 times faster in Swift than it would in Python. This same algorithm run in Objective-C would only be 2.8 times faster than in Python.

Apple WWDC 2014

Developers are very excited about this new language. Manesh Mistry, one of the creators of Monument Valley, a game that won an Apple Design Award at WWDC, said that the scripting power speed that will be available with Swift was “blowing [his] mind”. Mistry and co-developer Dan Gray agreed that Swift was one of the biggest announcements of WWDC.

Speed isn’t the only advantage Swift has over Objective-C. Objective-C was built in the 1980s, as an extension of the C language. Developers say that it is rather clunky (for example, its method names tend to be very long) and a difficult language for new developers to pick up. Frank Bentley, a mobile programming teacher at MIT, says that some of the more complex features of Objective-C coding “tends to trip up students” and that even in the case of experienced app developers beginning to use iOS “…coming from a Ruby or JavaScript or Python background; all of the overhead of Objective-C gets rather confusing.”

Therefore, in order to enable more developers to develop for iOS, Swift was designed with accessibility in mind. With automatically managed memory, three letter variables, and safe patterns that eliminate unsafe code, Swift’s design is clean and concise. According to Apple, “adding a single character [in Swift] can replace what used to be an entire line of code in Objective-C.” In addition to being an easier language for developers to use, Swift features an interactive Playground, which animates code as it is being written. This enables app developers to see their changes as they make them, and developers new to the language can be sure that their code does not contain any simple syntax errors or bugs.

Apple Swift playground

 
Example of an Interactive Playground

Swift, however, won’t be entirely unfamiliar to experienced iOS developers. It uses Objective-C’s object-oriented design and the best features from Objective-C.  Apple’s Cocoa and Cocoa touch frameworks will not change, and developers in these frameworks will easily be able to turn their old, Objective-C code into Swift through the migration process. Migration allows the developer to change pieces of Objective-C code into Swift and integrate the new Swift pieces back into their original Objective-C code, without having to rewrite their entire app in Swift.

The final version of Swift will be released in October, but the beta version is available now for download from Apple, along with a language tutorial and an overview of how to use Swift with Cocoa and Objective-C.

Story via Apple

Advertisement



Learn more about Apple
Electronic Products Magazine

Leave a Reply