This article originally appeared in TidBITS on 2016-06-13 at 5:45 p.m.
The permanent URL for this article is: http://tidbits.com/article/16570
Include images: Off

Playing Around with Swift on the iPad

by Michael E. Cohen

Stating that “We believe coding should be a required language in all schools,” Apple CEO Tim Cook announced during this year’s WWDC keynote that Apple was bringing the Swift Playgrounds [1] app to iPads later this year. Swift Playgrounds is an environment designed to help developers try out code quickly, accompanied by a bevy of lesson materials. And it’s all free.

[image link] [2]

Since its debut at WWDC two years ago, the Swift programming language has become increasingly popular (see “Swift: Who Is Apple’s New Programming Language For? [3],” 12 June 2014). In no small part, that’s because of its clarity and simplicity compared to Objective-C, the de facto programming language for OS X and iOS development for years. The first version of Swift debuted with an Xcode feature called Playgrounds that developers could use to write and execute sample code quickly, a boon both for learning the language and for prototyping code.

Swift Playgrounds for the iPad provides much of the same learning and prototyping capability as the Mac version and puts it on a handheld device. That makes it special already. Being able to craft and test a chunk of Swift code on the iPad and see how it performs is a boon to developers, who often may have programmatic inspiration strike while they’re miles from their keyboards. And that’s all without, mind you, having to run it in an iOS simulator on the Mac.

Add in a customized on-screen keyboard that provides all the special characters programming requires right on the main keyboard and include development-oriented QuickType assistance, and Swift Playgrounds becomes even more attractive. Supplement that with a code-snippet library for drag-and-drop coding, enhance it with a set of templates that offer working code to exploit iOS device features like the gyroscope and accelerometer, and throw in gestural editing (such as dragging to expand the scope of a FOR loop) and you have something really interesting.

[image link] [4]

Top it all off with the ability to easily import and export Playground code with Xcode on the Mac and you have a winning formula to entice developers to buy more iPads, as well as to lure hardened Objective-C developers to dabble in Swift.

But so much for developers who already know how to code. What about the kids? After all, aren’t playgrounds for kids?

They are, indeed. Most of Apple’s Swift Playgrounds for the iPad announcement and demo at the WWDC keynote focused on the lesson materials that Apple is also releasing with Swift Playgrounds. These lessons start slow, designed as they are for novice programmers at the grade-school level to sink their teeth into. The lessons feature puzzles to be solved and animated characters to be controlled by writing and executing Swift code. Accompanying them is a free book, part of Apple’s new “Everyone Can Code” initiative, titled “App Development with Swift [5],” as well as two teacher’s guides: “Swift Playgrounds (Teacher Guide)” and “App Development with Swift (Teacher Guide) [6].”

The combination of Swift Playgrounds and its ancillary instructional materials may be a winning formula to attract more schools and families with school-age children into buying iPads. Which is, let’s remember, how Apple funds projects like this.

With Swift Playgrounds for iPad, Apple is working hard to broaden the reach of its app ecosystem to developers and would-be developers at all levels. Just as important, Swift Playgrounds and its instructional accompaniments could well counter the inroads that inexpensive Chromebooks running Google’s Chrome OS have made into the education market, where they have begun to supplant iPads in a number of schools.

Swift Playgrounds is available to developers now, with a public beta coming next month and with App Store availability by this fall, although it may not be tied to the rest of the operating system releases promised for the same timeframe.

[1]: http://www.apple.com/swift/playgrounds/
[2]: http://tidbits.com/resources/2016-06/Swift-Playgrounds.png
[3]: http://tidbits.com/article/14812
[4]: http://tidbits.com/resources/2016-06/Swift-Playground-keyboard.png
[5]: https://itunes.apple.com/us/book/app-development-with-swift/id1118575552?mt=11&at=10l5PW
[6]: https://itunes.apple.com/us/book/app-development-with-swift/id1118577558?mt=11&at=10l5PW