iPad&iPhone user

Learning to code with Swift Playground­s as an adult

Apple’s Everyone Can Code initiative is laudable, but has a big gap to fill. Jason Cross reports

-

Apple thinks it is critically important that everyone learn how to code. It may not help you in your job directly, but it teaches useful skills and creates a basic knowledge of the fundamenta­l workings of the products and tools we all use every day. It’s not just something children should do at school, but an important part of an ongoing education for adults.

So, the company created an initiative called Everyone Can Code that aims to make it easy for anyone, from kids to adults, to learn the basics of writing code. Naturally, it’s centred around Apple’s Swift programmin­g language rather than, say, C++ or JavaScript. And it all starts with Swift Playground­s, a cute iPad app that teaches the fundamenta­ls of coding in a way so simple even young children can grasp it.

I am not a young child. I’m 43, and I have been glued to computers since my first Apple II. I decided to run through the Swift Playground­s activities to see if it can teach an old dog new tricks.

Starting from scratch(-ish)

I’m not a total stranger to programmin­g, but it would be a big understate­ment to say, “it’s been awhile”. I grew up writing simple BASIC programs on an Apple II at school, but it’s been more than 20 years since I wrote even a few lines of code. (That was C++ class back at university.) I went into this exercise with no clue what it’s like to use real modern developmen­t environmen­ts or what a modern language like Swift is like.

I’m not exactly a total novice, but I feel most comfortabl­e starting from the very beginning. Time to load up Swift Playground­s ( fave.co/2jm4Vvc).

And wow, it looks good, and it’s easy. So, so easy. This is clearly made for young children to use. I have no problem guiding around Byte, my little animated character, to understand the basic concepts of what a program is, but I can’t help but be turned off by how utterly simplistic Swift Playground­s is. If I was eight, this would have been a delight. At 43, it’s a little like curling

up to read a good novel and it turns out to be The Very Hungry Caterpilla­r.

While the juvenile appearance never fades, the mind-numbing simplicity doesn’t last long at all. Most adults will quickly power through the first few lessons. By the time you’ve moved on from Nested Functions to For Loops and then Conditiona­l Code you’ll be solving some real logic puzzles. (And if those terms confused you, take heart: the whole point of Swift Playground­s is to introduce you to them.) The challenges are not terribly difficult – the app accepts any solution that works and you can endlessly tweak yours to fix problems – but you have to actually exercise your brain.

Simply put, after about an hour, even grown adults should be fully engaged by Swift Playground­s’ playful coding puzzles. That’s a big win. Parents and children

can go through these activities together, and they can both really get something out of it.

Where it all breaks down

It turns out that, after a rather boring first few lessons, Swift Playground­s becomes thoughtful and engaging enough to capture the attention of adults. Your average middle-aged person who doesn’t know the first thing about programmin­g can spend an hour with the app every night, and in just a couple weeks they will probably finish all the lessons in Learn to Code 1 and Learn to Code 2.

That’s enough to learn a lot. Getting that far, a person would really understand what it means to code. They’ll understand how complex tasks are broken down into really simple tasks that are repeated and looped as needed, and how programs say “if this, do that, otherwise do this other thing”. Making use of these tasks to solve little logic puzzles, guiding Byte around his little 3D world, is charming and really makes the concepts stick.

Eventually you’ll go beyond just trying to guide Byte along a path, and start modifying and creating his little 3D world. If you go through Learn to Code 3, you’ll learn stuff that looks like real app developmen­t: coordinate­s and placing graphics and touch events.

But then what? Swift Playground­s teaches concepts and uses real Swift structure, but it’s not real code. It doesn’t make an app, it just guides Byte around and solves puzzles. Swift doesn’t have a real command called ‘collect Gem()’ after all. Swift Playground­s can satisfy your curiosity about what coding is and how

it works, but it doesn’t really let you write apps. Not even a simple basic one. The code you write can’t leave the app; it can’t even leave that particular puzzle page. If you want to actually make an app, Apple has another curriculum.

Bridging the gap

So you want to take your new-found knowledge of loops, if-else statements, and functions and write an app. Just bust out your iPad and open the Apple Store app to purchase a Mac.

That’s right, Apple’s actual code-writing program, Xcode, is only available for Mac. It’s free, to download from the Mac App Store ( fave.co/1OW6T1K). Then you’ll want to go to the iBooks store and grab Intro to App Developmen­t with Swift. When you start reading that e-book, it’ll prompt you to download some project

files you’ll use as you progress through the book. This is traditiona­l programmin­g instructio­n, and it’s not great. Reading along in a book, loading up sample code and making a few changes, taking little quizzes to make sure you understand the concepts is what learn-to-program-at-home courses have looked like for ages. Apple does a great job making the book and the project files clear and interactiv­e, but it’s a boring, businessli­ke slog compared to Swift Playground­s.

If Apple wants to really inspire people – both children and adults – to write code instead of just learning what code is, it needs to bridge the gap between the colourful puzzle-solving of Swift Playground­s and Xcode’s developer-centric environmen­t. Give us a transition phase that jettisons Byte in favour of a virtual iPhone screen. Walk us through the creation of a very simple app: something like a tip calculator, where the user inputs a pound amount and presses one of two buttons (15 or 20 percent) to calculate the tip. That’s not going to become your first App Store submission, but it’s the kind of thing a Swift Playground­s graduate could understand, and it performs a real-world task instead of navigating a cartoon character through a self-contained puzzle.

Did I mention you need to buy a Mac? It makes no sense that Swift Playground­s is exclusivel­y available for iPad, and Xcode is available exclusivel­y for Mac. What a huge barrier to learning it is to lock it behind yet another expensive purchase. This, from the company that just ran a prominent TV commercial where a precocious bright young girl uses her iPad for everything and asks, “What’s a computer?”

If you’re an adult who wants to learn to code, don’t let the child-friendly nature of Swift Playground­s dissuade you. It quickly becomes sophistica­ted enough to make it a worthwhile and satisfying way to learn about core programmin­g concepts.

But if you want to actually write usable code, you’re going to have to do some real work. You’ll need to use a Mac and Xcode to use the Swift knowledge you’ve learned, or else try to translate the concepts to a more portable language like JavaScript. Either way, you’ll be stuck with the old ‘book and sample code’ lessons that have plagued programmin­g education forever, making you feel like you’re back in high school.

 ??  ?? Go far enough in Swift Playground­s and you’ll learn sophistica­ted concepts like arrays
Go far enough in Swift Playground­s and you’ll learn sophistica­ted concepts like arrays
 ??  ?? Swift Playground­s starts off mind-numbingly basic, but stick with it
Swift Playground­s starts off mind-numbingly basic, but stick with it
 ??  ??
 ??  ?? If you want to write real apps, you have to hop on a Mac and go through a traditiona­l, boring, course
If you want to write real apps, you have to hop on a Mac and go through a traditiona­l, boring, course

Newspapers in English

Newspapers from Australia