Newly-introduced programming language gets mixed reception

Jun 5, 2014 12:36 GMT  ·  By

On June 2 Apple proudly introduced a new programming language that it’s been working on for four years. Dubbed Swift, the platform has a major vulnerability that involves the live-preview function, Playground.

Software engineer David Auerbach outlines the areas where Swift falls short of developers’ expectations, making it pretty clear that not everyone is a cheerleader for Apple’s new programming direction, especially with Swift being proprietary. But that’s a topic best left for actual coders to discuss.

A more serious issue with Swift involves an actual vulnerability that allows it to rinse your Mac and instantly delete everything in your home folder.

The warning comes from Steve Troughton Smith (@stroughtonsmith) on Twitter: “Protip: while in a Swift playground, for the love of God don't write system("cd ~; rm -rf *"). Runs-as-you-type has its downsides!”

Apple has yet to respond to the vulnerability, so if you’re planning to use Swift to code an app, whatever you do don’t write the aforementioned line of code. Swift will need a sandbox to protect the Mac from its live-preview function, Playground.

“Playgrounds make writing Swift code incredibly simple and fun,” says Apple, but forgets to say “dangerous too.”

“Type a line of code and the result appears immediately. If your code runs over time, for instance through a loop, you can watch its progress in the timeline assistant,” according to the description. The timeline displays variables in a graph, draws each step when composing a view, and can play an animated SpriteKit scene. When you’ve perfected your code in the playground, simply move that code into your project.”

Playgrounds allow developers to design new algorithms and watch the results every step of the way, create new tests and verify that they work before promoting into the test suite, and even experiment with new APIs.

“You can begin using Swift code immediately to implement new features in your app, or enhance existing ones,” Apple says. “New Swift code co-exists along side your existing Objective-C files in the same project, making it easy to adopt. And when iOS 8 and OS X Yosemite are released this fall, you can submit apps that use Swift to the App Store and Mac App Store.”

Xcode 6 beta is a free download for all registered Apple developers. The Swift Programming Language book can be downloaded free of charge from the iBooks Store. Guides for using Swift with Cocoa and Objective-C can be fount at developer.apple.com/swift.