Swift Playgrounds shows how anyone can learn to code
In June 2014 at its WWDC event keynote in San Francisco, Apple introduced a new coding language called Swift. The idea was to make coding easier, less frustrating and to offer you a real-time look at what your code actually meant. Swift Playgrounds, launched earlier this year, is an iPad designed to make it even simpler.
Apple’s mission is simple: to get as many kids and first-timers as possible learning the basics of coding. This week, that drive sees the company taking part in the Hour of Code as part of Computer Science Education Week which runs until 11 December. Free workshops will be held at Apple stores around the country.
If you’re not able to get to one with your kids, just fire up the iPad, download Swift Playgrounds and you’ll find a special Hour of Code session there. Or, if you’re a teacher, you can download Apple’s pre-made lesson guides and start your own session.
Right at the outset of starting up the Swift Playgrounds app – a free download from the App Store – you’re introduced to coding in the most simple way. Half of the screen is taken up with a real-time graphic showing a character called Byte in his own 3D world. The other half is a screen for inputting your code, with a basic description and guide on how to achieve the objectives of that lesson.
In every instance, the aim is to get Byte to pick up a gem and/or flick a switch on the floor. As you progress through the lessons, commands get more and more complicated to build up your knowledge of how to string together commands.
The first chapter of lessons take you through stringing together very basic commands. You don’t have to type them all out, you can just tap on the command you want from the selection at the bottom of the screen. This immediately cuts a considerable amount of time out of inputting code, removing probably the most tedious part of real coding.
Following on from that, you learn to build complex single commands by grouping together existing simple lines. For instance, in any level where the same group of moves is repeated multiple times, it’s better to build a new function made up of individual commands.
As an example, Byte needs to go up and down four sets of steps to collect a gem in one chapter. In this instance, it makes more sense to create one function that tells him to go up the stairs, collect the gem, then come back down and turn to the next set of steps, the repeat that three more times. It’s the difference between writing 28 lines of code and writing four.
One of the other great things about Swift Playgrounds is that if you make a mistake, and get commands in the wrong order, you don’t have to delete the entire list and start again. You simply tap on a line of code and drag it up or down to reorder.
While Swift Playgrounds will never be a tool to help you build a stonking new app, and become a coding wizard, it’s a really easy way of learning the basics. By gamifying the process, making input so easy to see and so visual, it’s about as user friendly as coding has ever been. We’ve tested it with some of our primary school age kids and, although initially tricky for them, they got into the groove eventually.
It stops lines of coding from looking like a jumbled mess or words and punctuation, and makes it far easier to understand. If you want to get into coding, or help your kids or pupils learn the basics, it’s one of the best ways to do it.