Macworld (USA)

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.

- BY JASON CROSS

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 kids should do at school, but an important part of an ongoing education for adults.

So, the company created an initiative called Everyone Can Code ( go.macworld. com/evcn) that aims to make it easy for anyone, from kids to adults, to learn the basics of writing code. Naturally, it’s centered 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 kids can grasp it.

I am not a young kid. 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 in middle school, but it’s been more than 20 years since I wrote even a few lines of code. (That was C++ class back in college.) 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 newbie, but I feel most comfortabl­e starting from the very beginning. Time to load up Swift Playground­s ( go.macworld.com/splg) on the ‘ol ipad…

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

While the juvenile appearance never fades, the mindnumbin­g 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 noggin.

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 collectgem() 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 super-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 a whole other curriculum.

BRIDGING THE GAP

So you want to take your newfound 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 real-codewritin­g program, Xcode, is only available for the Mac. It’s free, you just download it from the Mac App Store ( go.macworld. com/xcde). Then you’ll want to go to the ibooks store and grab Intro to App Developmen­t with Swift ( go.macworld. com/iads). When you start reading that ebook, 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 sucks. Reading along in a book, loading up sample code and making a few changes, taking little quizzes to make sure you understand the concepts…this is what learn-to-program-athome 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 kids and adults—to write code instead of just learning what code is, it needs to bridge the gap between the colorful puzzle-solving of Swift Playground­s and Xcode’s developerc­entric environmen­t. Give us a transition phase that jettisons Byte in favor 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 dollar amount and presses one of two buttons (15 or 20 percent) to calculate the tip. That’s not exactly 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 realworld 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 on the ipad, and Xcode is available exclusivel­y on the 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 kid-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 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 ol’ “book and sample code” lessons that have plagued programmin­g education forever, making you feel like you’re back in high school. ■

Did I mention you need to buy a Mac? It makes no sense that Swift Playground­s is exclusivel­y available on the ipad, and Xcode is available exclusivel­y on the Mac.

 ??  ??
 ??  ?? Swift Playground­s starts off mind-numbingly basic, but stick with it!
Swift Playground­s starts off mind-numbingly basic, but stick with it!
 ??  ?? 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.
 ??  ?? 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.
 ??  ?? You know, Apple. A computer is a thing you use to write apps.
You know, Apple. A computer is a thing you use to write apps.

Newspapers in English

Newspapers from Australia