Swift Playgrounds

25Apr19

I mentioned Swift Playgrounds in my Learning to Code post a few years back, but at that time I didn’t have a new enough iPad to try it for myself. That changed when I recently got an iPad Mini 5[1], so I’ve been running through the Learn to Code modules.

It’s like a puzzle game, that you solve with code

The setting is somewhat reminiscent of 2D puzzle games like Icicle Works or Chip’s Challenge, except that it’s 3D, and the character is moved with code rather than cursor keys.

Things start out very much in the vein of Turtle graphics that will be familiar to anybody who’s encountered Scratch. There’s the usual move_forward, turn_left, do_action type stuff; but it’s not long before you’re writing functions, doing loops, using conditional and logical operations and building algorithms – and that’s just Learn to Code 1. Learn to Code 2 gets into variables, types and arrays, plus a bunch of object oriented (OO) stuff, though without ever using words like ‘class’ or ‘constructor’.

I’ve personally found going through the first couple of modules more like playing a game, and less like learning a new language. Partly this makes me feel like I’ve learned how to play Swift Playgrounds, but maybe not (yet) learned much (idiomatic) Swift.

It’s not perfect, but it does seem very very good

There are a few recurrent annoyances:

  1. Getting the cursor where you want it sometimes seems to be an ordeal, and I’ve often found myself having to scroll the screen a little up/down to enable the cursor at all.
  2. The keyword suggestions above the keyboard are generally all you need. Until you need the ! operator, at which point you have to pull up the full keyboard.
  3. If it thinks you want to enter an integer then you’ll be given the numbers only keyboard, so to put in anything except an integer requires a bit of cursor jiggling hoop jumping – if only there was a button for ‘give me the whole keyboard’.

There were a few places where I wondered if I’d have been able to make progress if I didn’t already know a bit of Java/C# and the general way that OO languages work.

Look closely, and you’ll see that I’m cheating this level

It’s also possible to cheat some of the tests that let you move onto the next level (a route I chose to take a few times when it felt like I was ‘grinding’ and it was asking me to type in stuff I’d done already on earlier levels because it’s impossible to build a reusable library of functions, and too time consuming to copy/paste from previous work).

Beyond the annoyances noted above it seems to be an excellent way into programming and the logic behind it. The puzzle game element delivers regular dopamine hits, and the underlying syllabus has enough repetition to ensure that the key concepts are absorbed, but not so much that it becomes boring. Could you write a Swift program to solve a given problem after Learn to Code 1 & 2 – probably not[2], does it provide the right mental framework to underpin a programming mind set – certainly yes.

A friend was visiting at the weekend to collect their $son0 who had been visiting my $son0 and said that their $son1 had expressed an interest in programming as a career (and computer science as an A Level choice), but she was concerned that they’d never actually done any programming and hence didn’t really know if they liked it or not. I suggested that Swift Playgrounds could be a good acid test – the puzzle game element might be a bit basic/childish for a gaming addicted teenager, but the programming element is deep enough to determine if they’re into it (or not).

I made that recommendation because Swift Playgrounds seems to nail the very thin middle ground between the instant gratification of gaming, where the expectations of an entire generation have been calibrated by Minecraft; and the inherently deeper challenges of learning to write and (more importantly) debug code (that my generation was forced into if we wanted to play games, as we had to type them into BASIC 8 bit computers from magazine printouts and library books).

You need a recent iPad

I was hardly surprised that Swift Playgrounds didn’t work on my ancient iPad 2 when I first heard about it, but it seems that recent versions only work with ARKit (A9 or later CPU) capable models. On one hand that probably means that Playgrounds can do funky stuff with robots and drones and augmented reality, but it also means that those older iPads that people might want to hand down to their kids might not be any use for this means to learn programming, which is a shame.

Whether Swift Playgrounds is so good that it’s worth buying a new iPad for is a question my brother was scratching his head over as he left my place the other day (after my nephew had devoured the first few levels and had to be torn away).

There’s also a web version, which is not the same at all

Before I got my new iPad I’d come across the Online Swift Playground when I was trying to do some stuff with emoji flags[3]; but it’s very much an empty vessel for testing Swift code, and not a place to learn programming by playing a puzzle game.

Conclusion

I’m very impressed with Swift Playgrounds, and from everything I’ve seen it might just be the best way to get kids into a coding mindset. For anybody that’s already putting a reasonably recent iPad into the hands of their kids it’s something they should definitely try. Whether it’s worth buying an iPad for (or at least the deciding factor in getting an iPad versus something else) is a trickier question. I can only note that the £99 that my dad spend on a ZX81 would today buy a basic (32GB 9.7″) iPad and leave around £50 in change (at least according to this inflation calculator).

Notes

[1] The Mini 5 really is an impressive machine – I recently tweeted ‘Wow, no wonder the iPad mini 5 feels brisk, its single core @geekbench is faster than my desktop (Ryzen 5 2600) and my gaming laptop (i7-7700HQ)’. The only thing I’d change is the screen ratio (from 4:3 to 16:10) to make it small enough to fit in a jacket pocket like my 2013 Nexus 7 did.
[2] I’ve taken a glimpse at Learn to Code 3, which seems to move away from the puzzle game format and on to more open front end development, and of course Playgrounds itself is an open environment where anything that can be done with Swift can be tried out. So there’s lots there to fill the gap between the intro modules and for real coding.
[3] But then I ran into the terrible emoji support for Windows 10, where I got ISO country letter pairs rather than actual flags :(



No Responses Yet to “Swift Playgrounds”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


%d bloggers like this: