New iPhone 7 tool could make you rich

Before you go, we thought you'd like these...

I've been in the tech publishing industry for 25 years, but that no more makes me a programmer than someone watching football on TV for a quarter of a century makes them a quarterback.

Code is my Achilles' heel. Its proximity to formulas makes me queasy. It's not that I can't understand any code. Back in high school, I was a whiz at geometry, but then stumbled badly in chemistry and trigonometry. Similarly, I spent a summer learning BASIC and coding an incredibly simple program. I've also tackled HTML, but when it came to JavaScript, I could do some, but almost entirely based on code I'd copied and modified from other sites.

Real programming and code baffles and terrifies me.

A few years ago, Apple introduced the Swift programming language as a sort of simple gateway drug for deeper, Xcode programming. It could be the foundation of real apps in the formal language.

The first time I saw some of the code up on screen at WWDC 2014, I felt like I sort of got it. I recognized some of the words and structure.

That's why, ostensibly, Apple's new, free code-training app Swift Playgrounds should be for me and much more agile-minded students. During the recent iPhone 7 launch, Apple also introduced Everyone Can Code, an educational initiative designed to help get code training — specifically Swift code training — into schools and curriculums. Playgrounds is a key part of that program.

On Tuesday, Apple drops Swift Playgrounds in the app store. I've been immersing myself in this iPad-based code school for a week.

Now, as I stare at a Swift Playground lesson plan, I realize I was half right. Yes, there is something intrinsically knowable about Swift, but there's still the code-theory leap that my mind struggles to make.

This, of course, is probably just me.


Swift Playgrounds is partially just that, a coding playground where you can repeatedly try out different commands, calls and code variations to propel entertaining animations over and over again. You are, in essence, the code-breaker and maker here.

And you're doing it on the iPad, a platform that's generally thought of as the place where you consume the result of code, not create it.

The basic lesson plan, called Fundamentals of Swift (there's also second one called, naturally, Beyond the Basics), is set up so there's code on the left-hand side of the screen and an animated environment on the right that's driven, almost in real time, by your code. Each lesson offers a challenge designed to teach you one rudimentary piece of Swift code. You can also try some of the challenges, which let you alter code and change the functionality of pre-built games and apps like Blink. Blink is a simple grid — almost a Minesweeper-style game — where surrounding cubes influenced the kind color cube I could have in cube clusters. Apple plans on adding more of those challenges over time.

Fundamentals, though, eases you into code. It starts with command and the style in which Swift commands are written. At this level, the commands use English language words and follow a clear and consistent pattern. What's more, the iPad's virtual keyboard and QuickType suggestions immediately offer the nearest, best code option as soon as you start typing a letter. Typing in "t" will, for example, show "turnLeft ()" which is, naturally a turn left command. Typing "m" brings up "moveForward." I can then click on any of the commands to add them.

To my surprise and pleasure, I breezed through a series of command lessons. Each time driving the animated character, Byte (you can choose from among three animated oddballs), to move forward, toggle switches and collect gems in the right order or, at least, to the satisfaction of the app, which would cheer my progress.


Things got a bit trickier at Functions, which let me group some of these commands or tasks. It took me a while to figure out that I define the Function, with all its embedded commands, at the top of the programs. After that, I just call the Function below to execute the series, as many times as I wanted. In between the Functions, I used smaller commands, like "moveForward ()" to tie together these groupings, sort of like the cartilage that joins more complex bone.

To be honest, I was stumped by this simple fact for a good 30 minutes and Swift Playgrounds didn't quite help. One reason is that, while you can write code, compile (done by simply hitting "Run My Program") and run it over and over again, watching as Byte runs and, sometimes, stumbles through, your poorly written commands, the app doesn't highlight the exact command that's executing at the exact moment that Byte is performing an action. That's something that would have been invaluable to me as I tried to debug my code.

To get around this, I added spaces between chunks of code so I could keep track of what Byte was doing in relation to the code. This helped me make it through Functions to Loops. I then somehow solved the first lesson in Loops in one try. Seriously, it took me about a minute.

Swift Playgrounds would let me go as far as I wanted with the code. The first Lesson goes all the way into Algorithms, which scare me.

However, if I can get through to Beyond the Basics, Playgrounds will even let me write code that accesses the iPad's sensors and camera. I'll also be able to import my own visual assets and program them, all of which is almost enough to make me want to push through my coding fears.

Whatever I choose to do, the whole system is self-guided and designed to let me jump around as much as I like. I can even accelerate the program playback, if I want (worth doing since Byte moves through tasks pretty slowly – a playback speed slider would be helpful here). The problem with doing that, though, is if you jump ahead, you get lost, as I did. Some things still made sense, while others did not. Learning to code requires patience, which is why the animated program playground is so smart. It turns learning to program into a series of puzzles and games. The desire to learn is driven by the desire to solve the puzzle.


The more time I spent within Swift Playgrounds, the more I realized that it's really written exactly for people like me, as well as children and people of all ages, who want to code.

I can't say that I ever felt comfortable coding or that what I've learned rooted itself into some hidden cranny in my brain – a half-day away from it and I feel lost. However, that isn't entirely true; I am starting to see the patterns. And now I remember something about my old HTML and JavaScript coding days.

At the start, they too left me confused and bereft, but through sheer repetition and a ton of trial and error, I eventually became an expert at HTML and comfortable with at least 60 percent of JavaScript.

That's what Swift Playgrounds asks of you. Do the code and do it again, with the carrot of an entertaining avatar plating out your code creations over and over again, looking sad when you fail and elated when you succeed.

I don't know if this is the beginning of me, perhaps, coding a basic app and graduating to Xcode or not (probably not), but for anyone who wants to get started learning (or teaching) solid, baseline coding skills in a touch-based environment, Swift Playground is an excellent place to start.

Read Full Story

People are Reading