Programming playgrounds: Swift on an iPad?

If there is one issue in education, and our children’s future, on which opinion is unanimous, it is the importance of them becoming thoroughly computer-literate, which inevitably involves learning at least the rudiments of programming.

What is often less apparent is the value of learning to analyse problems and tasks, so that they can be turned into code, and related methods such as debugging. There was a time when learning rhetoric and logic were considered essential in any decent education, but for a long time schools and even universities have shunned such universal skills. Perhaps they seem too prescriptive, or teachers themselves feel too distant from the subjects to attempt them – and in many cases such subjects are completely omitted on the prescribed curriculum.

When Apple announced Swift Playgrounds at WWDC in the summer, there was initial excitement which cooled noticeably as people got to learn more about it. At the time, it wasn’t clear how generally useful it would prove for real-world code development, and some felt that without a proper development environment running on iOS, it would only be an educational toy.

There are other programming playgrounds already. Apple’s Xcode has supported its own Swift Playgrounds, there is the superb but frustratingly-limited Haskell for OS X, and more. Previous generations had various forms and flavours of Basic, Smalltalk, Logo, derivatives of Scheme, and of course Niklaus Wirth developed the Pascal language primarily for teaching purposes.

But none seems to have set the schools on fire. Even the hugely popular Raspberry Pi – wonderful though it is – has only sold ten million. Apple has been selling that number, or more, of iPads every quarter for the last five years. Many of those iPads are used by schoolchildren, either at school or in the home.

This week, with the release of iOS 10, anyone with an iPad can now download (at no cost) Swift Playgrounds, and start learning to program with it. I therefore wanted to see for myself whether this breaks new ground and I should encourage my grandson to use it, or is it just pretty and pointless?

To use Swift Playgrounds, all you need is an iPad running iOS 10, with a bit of free storage for it, lessons, and some playgrounds. Apple has copious documentation on the Swift language, examples of how to make your own playgrounds on a Mac, and more on the Swift documentation page, and details about Swift Playgrounds here.

swiftplay1

Shipping alongside the app are two courses, Learn to Code 1 and 2, and a set of graded playground Challenges, covering beginner and intermediate levels. No doubt Apple will expand those in due course, and third parties are welcome too – including anyone with a Mac and Xcode version 8, who can create their own custom playgrounds.

The Learn to Code courses are self-contained. Each module starts with a short slide show, then quickly takes the student into a series of problems, which they solve in a built-in playground. These start, in the first course, from the absolute beginning – no prior concepts of programming are required, so long as the student can read, type into their iPad, and has basic numeracy.

swiftplay2

The early lessons borrow from previous experience with Logo, in which the student learned to direct a robot. Here Apple recasts this in the present, with Byte, a cartoon dinosaur, who makes his way through obstacle mazes in glorious 3D with neat animation.

The pace is quite fast, but the learning environment friendly, helpful, and forgiving. Students can run, halt, edit their code, re-run, and so on to iteratively solve each problem, and hints are available. Although the problems are far from insoluble, they are sufficient to get anyone thinking. Apple does not make a big thing about trying to teach principles as such, but the problems cunningly inculcate those principles in the mind. The great majority of students should quickly start thinking in more algorithmic ways, and even the less interested or able should be gently helped along that road.

swiftplay3

As someone who regularly spent long nights thrashing out novel geometric algorithms on the living room floor over twenty-five years ago, I found Apple’s problems completely absorbing and challenging. I really enjoyed tackling them, and the Swift Playgrounds environment is the best way to explore programming in this way. The only wish on my list is for some form of step and trace through the Swift code as it executes, something featured in most development environments but seemingly lacking here (or at least unused).

If you have programmed already, and want to learn Swift, or you want to improve your skills, the Learn to Code courses are more of a problem. They are carefully structured, and diving in part way through is very difficult, because each module builds on the previous, and relies on your increasing familiarity with the Playgrounds environment. It is, therefore, probably best to start at the beginning of Learn to Code 1, even if you won’t encounter any really new stuff until Learn to Code 2. Besides, tackling the problems will only hone your coding skills.

swiftplay4

The Challenges playgrounds currently available, even those marked as being suitable for beginners, assume the skills learned throughout the respective courses. I’d recommend that students complete most, if not all, of Learn to Code 1 before tackling the beginner Challenges, otherwise much of them will appear cryptic, and their value will be reduced.

Overall, I am greatly impressed with Swift Playgrounds as a way of learning to program, and will be field-testing it with my grandson next. It is not, though, a platform for developers to use for ‘serious’ programming: even a basic MacBook Air with Xcode is far more suitable for that task. But you didn’t really expect Apple to let you execute all your own code in its walled garden, did you?