Learn­ing to code with Swift Play­grounds as an adult

Ap­ple’s Ev­ery­one Can Code ini­tia­tive is laud­able, but has a big gap to fill. Ja­son Cross re­ports

iPad&iPhone user - - FEATURE -

Ap­ple thinks it is crit­i­cally im­por­tant that ev­ery­one learn how to code. It may not help you in your job di­rectly, but it teaches use­ful skills and cre­ates a ba­sic knowl­edge of the fun­da­men­tal work­ings of the prod­ucts and tools we all use every day. It’s not just some­thing chil­dren should do at school, but an im­por­tant part of an on­go­ing ed­u­ca­tion for adults.

So, the com­pany cre­ated an ini­tia­tive called Ev­ery­one Can Code that aims to make it easy for any­one, from kids to adults, to learn the ba­sics of writ­ing code. Nat­u­rally, it’s cen­tred around Ap­ple’s Swift pro­gram­ming lan­guage rather than, say, C++ or JavaScript. And it all starts with Swift Play­grounds, a cute iPad app that teaches the fun­da­men­tals of cod­ing in a way so sim­ple even young chil­dren can grasp it.

I am not a young child. I’m 43, and I have been glued to com­put­ers since my first Ap­ple II. I de­cided to run through the Swift Play­grounds ac­tiv­i­ties to see if it can teach an old dog new tricks.

Start­ing from scratch(-ish)

I’m not a to­tal stranger to pro­gram­ming, but it would be a big un­der­state­ment to say, “it’s been awhile”. I grew up writ­ing sim­ple BA­SIC pro­grams on an Ap­ple 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 uni­ver­sity.) I went into this ex­er­cise with no clue what it’s like to use real mod­ern de­vel­op­ment en­vi­ron­ments or what a mod­ern lan­guage like Swift is like.

I’m not ex­actly a to­tal novice, but I feel most com­fort­able start­ing from the very be­gin­ning. Time to load up Swift Play­grounds ( fave.co/2jm4Vvc).

And wow, it looks good, and it’s easy. So, so easy. This is clearly made for young chil­dren to use. I have no prob­lem guid­ing around Byte, my lit­tle an­i­mated char­ac­ter, to un­der­stand the ba­sic con­cepts of what a pro­gram is, but I can’t help but be turned off by how ut­terly sim­plis­tic Swift Play­grounds is. If I was eight, this would have been a de­light. At 43, it’s a lit­tle like curl­ing

up to read a good novel and it turns out to be The Very Hun­gry Cater­pil­lar.

While the ju­ve­nile ap­pear­ance never fades, the mind-numb­ing sim­plic­ity doesn’t last long at all. Most adults will quickly power through the first few les­sons. By the time you’ve moved on from Nested Func­tions to For Loops and then Con­di­tional Code you’ll be solv­ing some real logic puz­zles. (And if those terms con­fused you, take heart: the whole point of Swift Play­grounds is to in­tro­duce you to them.) The chal­lenges are not ter­ri­bly dif­fi­cult – the app ac­cepts any so­lu­tion that works and you can end­lessly tweak yours to fix prob­lems – but you have to ac­tu­ally ex­er­cise your brain.

Sim­ply put, af­ter about an hour, even grown adults should be fully en­gaged by Swift Play­grounds’ play­ful cod­ing puz­zles. That’s a big win. Par­ents and chil­dren

can go through these ac­tiv­i­ties to­gether, and they can both re­ally get some­thing out of it.

Where it all breaks down

It turns out that, af­ter a rather bor­ing first few les­sons, Swift Play­grounds be­comes thought­ful and en­gag­ing enough to cap­ture the at­ten­tion of adults. Your av­er­age mid­dle-aged per­son who doesn’t know the first thing about pro­gram­ming can spend an hour with the app every night, and in just a cou­ple weeks they will prob­a­bly fin­ish all the les­sons in Learn to Code 1 and Learn to Code 2.

That’s enough to learn a lot. Get­ting that far, a per­son would re­ally un­der­stand what it means to code. They’ll un­der­stand how com­plex tasks are bro­ken down into re­ally sim­ple tasks that are re­peated and looped as needed, and how pro­grams say “if this, do that, oth­er­wise do this other thing”. Mak­ing use of these tasks to solve lit­tle logic puz­zles, guid­ing Byte around his lit­tle 3D world, is charm­ing and re­ally makes the con­cepts stick.

Even­tu­ally you’ll go be­yond just try­ing to guide Byte along a path, and start mod­i­fy­ing and cre­at­ing his lit­tle 3D world. If you go through Learn to Code 3, you’ll learn stuff that looks like real app de­vel­op­ment: co­or­di­nates and plac­ing graph­ics and touch events.

But then what? Swift Play­grounds teaches con­cepts and uses real Swift struc­ture, but it’s not real code. It doesn’t make an app, it just guides Byte around and solves puz­zles. Swift doesn’t have a real com­mand called ‘col­lect Gem()’ af­ter all. Swift Play­grounds can sat­isfy your cu­rios­ity about what cod­ing is and how

it works, but it doesn’t re­ally let you write apps. Not even a sim­ple ba­sic one. The code you write can’t leave the app; it can’t even leave that par­tic­u­lar puzzle page. If you want to ac­tu­ally make an app, Ap­ple has an­other cur­ricu­lum.

Bridg­ing the gap

So you want to take your new-found knowl­edge of loops, if-else state­ments, and func­tions and write an app. Just bust out your iPad and open the Ap­ple Store app to pur­chase a Mac.

That’s right, Ap­ple’s ac­tual code-writ­ing pro­gram, Xcode, is only avail­able for Mac. It’s free, to down­load from the Mac App Store ( fave.co/1OW6T1K). Then you’ll want to go to the iBooks store and grab In­tro to App De­vel­op­ment with Swift. When you start read­ing that e-book, it’ll prompt you to down­load some project

files you’ll use as you progress through the book. This is tra­di­tional pro­gram­ming in­struc­tion, and it’s not great. Read­ing along in a book, load­ing up sam­ple code and mak­ing a few changes, tak­ing lit­tle quizzes to make sure you un­der­stand the con­cepts is what learn-to-pro­gram-at-home cour­ses have looked like for ages. Ap­ple does a great job mak­ing the book and the project files clear and in­ter­ac­tive, but it’s a bor­ing, busi­nesslike slog com­pared to Swift Play­grounds.

If Ap­ple wants to re­ally in­spire peo­ple – both chil­dren and adults – to write code in­stead of just learn­ing what code is, it needs to bridge the gap be­tween the colour­ful puzzle-solv­ing of Swift Play­grounds and Xcode’s de­vel­oper-cen­tric en­vi­ron­ment. Give us a tran­si­tion phase that jet­ti­sons Byte in favour of a vir­tual iPhone screen. Walk us through the cre­ation of a very sim­ple app: some­thing like a tip cal­cu­la­tor, where the user in­puts a pound amount and presses one of two but­tons (15 or 20 per­cent) to cal­cu­late the tip. That’s not go­ing to be­come your first App Store sub­mis­sion, but it’s the kind of thing a Swift Play­grounds grad­u­ate could un­der­stand, and it per­forms a real-world task in­stead of nav­i­gat­ing a car­toon char­ac­ter through a self-con­tained puzzle.

Did I men­tion you need to buy a Mac? It makes no sense that Swift Play­grounds is ex­clu­sively avail­able for iPad, and Xcode is avail­able ex­clu­sively for Mac. What a huge bar­rier to learn­ing it is to lock it be­hind yet an­other ex­pen­sive pur­chase. This, from the com­pany that just ran a prom­i­nent TV com­mer­cial where a pre­co­cious bright young girl uses her iPad for ev­ery­thing and asks, “What’s a com­puter?”

If you’re an adult who wants to learn to code, don’t let the child-friendly na­ture of Swift Play­grounds dis­suade you. It quickly be­comes so­phis­ti­cated enough to make it a worth­while and sat­is­fy­ing way to learn about core pro­gram­ming con­cepts.

But if you want to ac­tu­ally write us­able code, you’re go­ing to have to do some real work. You’ll need to use a Mac and Xcode to use the Swift knowl­edge you’ve learned, or else try to trans­late the con­cepts to a more por­ta­ble lan­guage like JavaScript. Ei­ther way, you’ll be stuck with the old ‘book and sam­ple code’ les­sons that have plagued pro­gram­ming ed­u­ca­tion for­ever, mak­ing you feel like you’re back in high school.

Go far enough in Swift Play­grounds and you’ll learn so­phis­ti­cated con­cepts like ar­rays

Swift Play­grounds starts off mind-numb­ingly ba­sic, but stick with it

If you want to write real apps, you have to hop on a Mac and go through a tra­di­tional, bor­ing, course

Newspapers in English

Newspapers from UK

© PressReader. All rights reserved.