Learning to code with Swift Playgrounds 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 fundamental 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.
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 Playgrounds activities to see if it can teach an old dog new tricks.
Starting from scratch(-ish)
I’m not a total stranger to programming, but it would be a big understatement 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 development environments or what a modern language like Swift is like.
I’m not exactly a total novice, but I feel most comfortable starting from the very beginning. Time to load up Swift Playgrounds ( 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 Playgrounds 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 Caterpillar.
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 Conditional Code you’ll be solving some real logic puzzles. (And if those terms confused you, take heart: the whole point of Swift Playgrounds 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 Playgrounds’ 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 Playgrounds becomes thoughtful and engaging enough to capture the attention of adults. Your average middle-aged person who doesn’t know the first thing about programming 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 development: coordinates and placing graphics and touch events.
But then what? Swift Playgrounds 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 Playgrounds 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 Development 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 traditional programming instruction, 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 interactive, but it’s a boring, businesslike slog compared to Swift Playgrounds.
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 Playgrounds and Xcode’s developer-centric environment. 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 Playgrounds 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 Playgrounds is exclusively available for iPad, and Xcode is available exclusively 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 Playgrounds dissuade you. It quickly becomes sophisticated enough to make it a worthwhile and satisfying way to learn about core programming concepts.
Go far enough in Swift Playgrounds and you’ll learn sophisticated concepts like arrays
Swift Playgrounds 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 traditional, boring, course