On Monday, Apple announced a new programming language called Swift for iOS and OS X app development. As a language, it’s extremely similar to C and Objective-C with a couple exceptions. Apple’s mission with Swift is to provide easy coding, combined with security and efficiency as an iteration to Objective-C without straying too far from the source. As a result, Swift code will work side-by-side with Objective-C code.
To introduce developers to Swift, Apple published what amounts to a brochure for the programming language.
Swift is the brainchild of Chris Lattner, who describes its history on his home page. He started work in 2010 and the project slowly grew until it became a major focus of the Apple Developer Tools group in 2013.
“The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas,” Lattner writes. He also adds that Swift drew a lot of inspiration from many other languages such as Objective-C, Rust, Haskell, Ruby, Python, C#, CLU and others.
Swift iterates on Objective-C’s syntax by taking the former language’s expressive coding capability–to allow developers to produce clear, readable code–but drops the need for semicolons to terminate statements. Putting more than one statement on a single line, however, still requires semicolons to separate them.
To make coding both easier and safer, Swift does type inference as well as acts as a safe typed language. With type inference, developers do not need to declare types for variables similar to scripting languages such as PHP. Since this can lead to misuse of variables down the line–attempting to assign an Int to a String–Swift’s compiler performs type checks at compile time and marks any such mismatch as an error allowing the developer to catch and fix problems early.
The IDE packaged with Swift includes the capability to watch code run as it’s being written by the developer. With a Playground, the moment a line of code is written the result appears in a display. Loops can be watched with the timeline assistant and animations can even be played out–changing as the code is modified by the developer.
Once the code is perfected by the developer to “look” correct in the Playground, the developer can move the code right back into the project.
Playgrounds provide an interactive way for developers to test new algorithms, create tests and try them out before deploying them, or even simply experiment with Swift coding.
Interactive code displays are not new, but are fairly common to IDEs for web scripting–where code is often used for UI or interaction with users. It’s addition to Swift is part of a slowly rising trend, according to programming guru David Pollack, quoted in Wired.
“This isn’t necessarily an Apple invention, but it is something that has been bubbling up over the last few years,” he says.
The announcement of Swift has come with a bit of fanfare from Apple, but how will it affect developers in general?
According to Benzinga.com, analysts from Barclays feel that the announcement of Swift will give Apple developers a quicker path to getting into the iOS app market than the Android app market. Thus giving Apple an “important competitive advantage.”
Also according to Benzinga, analysts from Credit Suisse see Swift as appealing directly to Apple developers.
Swift’s compatibility with Objective-C projects also means that developers who already have code bases can start playing with the new language immediately. This provides a perfect segue for the curious and resonates with Apple appealing to developers.
The nuts and bolts
Developers interested in the syntax changes, mechanics, and underlying features can learn more from the thorough documentation Apple has provided.
Latest posts by Kyt Dotson (see all)
- Onchain joins with Alibaba for blockchain-powered email evidence bank - October 20, 2016
- Bitcoin Weekly: Bitcoin in Europe, blockchain financial news from China and the Middle East - October 19, 2016
- Microsoft Research paper points to touch-sensitive VR interfaces - October 17, 2016