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.

Macworld (USA) - - Contents - BY JA­SON CROSS

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 ev­ery day. It’s not just some­thing kids 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 ( go.mac­world. com/evcn) 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­tered 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 kids can grasp it.

I am not a young kid. 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.


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 in mid­dle school, but it’s been more than 20 years since I wrote even a few lines of code. (That was C++ class back in col­lege.) I went into this ex­er­cise with no clue what it’s like to use real mod­ern devel­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 new­bie, but I feel most com­fort­able start­ing from the very be­gin­ning. Time to load up Swift Play­grounds ( go.mac­world.com/splg) on the ‘ol ipad…

…And wow, it’s cute! And easy! So, so easy. This is clearly made for young chil­dren to grok. 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 were 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 Good­night Moon.

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 lessons. 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 nog­gin.

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.


It turns out that, af­ter a rather bor­ing first few lessons, 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 ev­ery night, and in just a cou­ple weeks they will prob­a­bly fin­ish all the lessons 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 devel­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 su­per-sim­ple ba­sic one.

The code you write can’t leave the app; it can’t even leave that par­tic­u­lar puz­zle page! If you want to ac­tu­ally make an app, Ap­ple has a whole other cur­ricu­lum.


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 real-codewrit­ing pro­gram, Xcode, is only avail­able for the Mac. It’s free, you just down­load it from the Mac App Store ( go.mac­world. com/xcde). Then you’ll want to go to the ibooks store and grab In­tro to App Devel­op­ment with Swift ( go.mac­world. com/iads). When you start read­ing that ebook, 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 sucks. 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…this is what learn-to-pro­gram-ath­ome courses 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 kids and adults—to write code in­stead of just learn­ing what code is, it needs to bridge the gap be­tween the col­or­ful puz­zle-solv­ing of Swift Play­grounds and Xcode’s de­vel­op­er­centric en­vi­ron­ment. Give us a tran­si­tion phase that jet­ti­sons Byte in fa­vor 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 dol­lar amount and presses one of two but­tons (15 or 20 per­cent) to cal­cu­late the tip. That’s not ex­actly 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 re­al­world task in­stead of nav­i­gat­ing a car­toon char­ac­ter through a self-con­tained puz­zle.

Did I men­tion you need to buy a Mac? It makes no sense that Swift Play­grounds is ex­clu­sively avail­able on the ipad, and Xcode is avail­able ex­clu­sively on the 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 kid-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 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 portable lan­guage like Javascript. Ei­ther way, you’ll be stuck with the ol’ “book and sam­ple code” lessons that have plagued pro­gram­ming ed­u­ca­tion for­ever, mak­ing you feel like you’re back in high school. ■

Did I men­tion you need to buy a Mac? It makes no sense that Swift Play­grounds is ex­clu­sively avail­able on the ipad, and Xcode is avail­able ex­clu­sively on the Mac.

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

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

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

You know, Ap­ple. A com­puter is a thing you use to write apps.

Newspapers in English

Newspapers from USA

© PressReader. All rights reserved.