Swift: how Apple’s new coding language lives up to its name
By Dian Tjondronegoro, Queensland University of Technology
As Apple’s Worldwide Developers Conference (WWDC) winds up in San Francisco today, 1,000 Apple engineers and 5,000 developers will return to their parts of the world armed with Apple’s own programming language.
Apple is the latest tech firm to produce their own programming language (Google and Microsoft also have their own languages) and Swift can be used by Apple developers as of today with 677 pages of documentation available in the iBooks store.
So what’s so good about Swift?
It pretty much comes down to speed.
While Apple (and other companies) supply the hardware, developers ultimately bring the most utility value out of technologies. The faster developers can code, the more apps can be created.
So let’s have a look at why Swift is the next big thing (and why developers should take the time to learn a new language, as it were):
Swift is much easier to code with. Swift looks much “cleaner” than traditional code. In addition to getting rid of nested brackets and semicolons (which makes code look very complex and harder to maintain), programmers can now use inferred types, which means that variables and constants can be declared without necessarily specifying the data type.
Developers can reduce debugging time over mundane and trivial errors (if you’re interested in the nitty-gritty, Swift manages unsafe codes by self-managing memory, preventing overflows – in arrays, for example – and properly handling nil objects).
It also means that new developers can be spared the need to learn Objective-C’s complex and verbose syntaxes (but Swift will sit alongside existing Objective-C and C codes).
Swift is fast and powerful. Fast programming is a key ingredient in Apple’s new hardware and software capabilities. Swift codes will be compiled using the same high-performance compiler, and it will be run natively to combine the best features from Objective-C and C.
Based on the presentation in WWDC, we saw statistics showing complex algorithms can be run much faster than Objective-C.
Swift supports “interactive playgrounds”. “Interactive playgrounds” allow developers to immediately see the results of changing codes and keep track of progress timelines. This is particularly useful for debugging complex loops, algorithms and animations.
Speaking of new developments …
As widely expected, Apple joins Google and Microsoft’s moves towards delivering health and home automation applications, as well as supporting stronger integration between native features (such as Siri and Notification View) and third-party apps and sensors.
The Health app joins Samsung’s Gear Fit, Nike and Fitbit to bring health and fitness data, measured by mobile and wearable devices, into our palms.
A new tool for developers called HealthKit adds to the standard activity, heart rate and diet measurements by allowing developers to create third-party apps and sensors to measure factors such as blood pressure and sleep patterns.
Users can also create emergency cards with important health information such as allergies and blood types, accessible from the lock screen and emergency call screen.
Another development tool – HomeKit – will let us control aspects of our homes (such as lights and temperature) using our phones.
To enable natural interactions with our phone for home and health apps, iOS has evolved to allow Siri be hands free, similar to its Android counterpart Google Now.
We could say: “Hey Siri, I’m ready for bed”, then the lights will automatically dim for sleep and the phone will go into “do not disturb” mode – perhaps even playing our favourite relaxing music.
With the introduction of Swift, we can expect to see more apps than ever – truly building upon Apple’s 2007 slogan, “There’s an app for everything”.
Dian Tjondronegoro is a member of IEEE and ACM.