David Briddock reviews Apple's new interactive coding experience for the iPad generation
For many, the act of creating apps simply by typing code statements into an editor can seem somewhat magical. Yet coding isn't just for software wizards or a gifted minority. With modern tools and computing platforms, it's something anyone can do.
The importance of coding as a fundamental skill is finally being realised by the educational community and government bodies. Indeed, coding is now a key part of the educational curriculum. It's also an essential ingredient in the 'constructional thinking' movement - something that encompasses computing systems and electronic hardware hacking.
Constructional thinking is now seen as a crucial ability in our increasingly tech-filled world and a foundation for many other creative pursuits. This is something Apple itself recognised when it said, "Learning to code teaches you how to solve problems and work together in creative ways."
Apple already has a powerful development environment called Xcode that can be used to write apps for its macOS-based PCs and iOS devices like the iPhone and iPad. But it falls well short as an ideal tool for someone taking their first coding steps.
Xcode Problems
Apple's Xcode environment has been around since 2003. The language of choice has historically been Objective-С, a specialised form of С with a rather idiosyncratic syntax. More recently, Apple has introduced a new language called Swift and something called Xcode Playgrounds.
Swift isn't a complete replacement for Objective-С, but it does remove some of those idiosyncratic features of this aging language, and the Xcode Playgrounds introduced a more interactive coding experience complete with graphical feedback.
However, Swift doesn't make it easy for coding newbies to get to grips with basic programming concepts and techniques. The learning curve remains steep. To build anything, you'll need focus and determination plus a considerable amount of time and patience.
You'll also need a pretty powerful, fairly new Apple computer to run Xcode. If all you own is an iPad, or your PC runs Windows, ChromeOS or Linux, getting into Apple software development turns out to be an expensive business.
Organisations like Google, Microsoft and MIT have already launched a number of newbie-focused coding languages, tools and interactive platforms. These run on a wide variety of operating systems, and some require nothing more than a web browser plus an online account. They allow coders to write programs that are cross-compiled into native apps for PCs or Android and Apple mobile devices and even wearables.
For example, the MIT snap-together block-based AI2 tool for creating Android apps is particularly easy to use. The Raspberry Pi platform, with its Python and Scratch language support, is already a firm favourite with educational establishments. And now there's the BBC Micro Bit too.
Enter Swift Playgrounds
Apple was missing out. It needed a new approach to gain a foot hold in the constructional thinking education arena. Something that would make coding look cool and accessible. A product that targeted younger children who are familiar and comfortable with today's technology, but who haven't yet been exposed to software coding.
The answer Apple came up with is a Swift Playgrounds app for its iPad device family. Part of Apple's 'Everyone Can Code' initiative (apple.com/education/everyone-can-code), an early version of this app first appeared as part Apple's iOS 10 beta release. The finalised version was synchronised with the official iOS 10 update rollout, which kicked off around mid-September.
This is the first time Apple has released an iOS-native development environment. But it feels the time is now right. After all, the iPad processor is certainly powerful enough, and the Swift language itself is now both stable and mature.
Even better, Swift Playgrounds is available to just about every iPad owner. The full supported list includes the iPad Air and Air 2, the iPad Mini 2, 3 and 4, plus the new iPad Pro models. If you have a fourth-generation 32-bit iPad, then I'm sorry to say you're out of luck.
First Impressions
As you open Swift Playgrounds for the first time, you'll be taken through an introduction. This is followed by the playground window and an option to see a list of lessons and tutorials. You can create any number of 'playgrounds' from a list of templates.
What you definitely won't see is a classic code editor. Begin with an introductory lesson (more on this later), and you'll be presented with an interactive multi-level 3D world that you can rotate with your fingers and zoom in or out using pinch gestures.
Inside this 3D world, you can select from three programmable characters. One is called 'Byte', a giant orange cartoon-like being with a single eye and yellow trunks. You can control Byte by issuing commands via code. For example, 'moveForwardO' or 'turnLeftO'. By putting these commands together with loops and conditional ('if') statements, you guide Byte around each level.
In concept, this is rather like a modern, graphically rendered take on the classic Turtle Graphics programs of the 1980s, where you controlled an on-screen or physical turtle robot using Logo language commands.
As you'd expect, the load and screen update times are far better and the graphics crisper with the latest iPad models. With older tablets, the 3D rendering has a lower-resolution look, and things happen a little more slowly.
Lessons
When it comes to coding the lessons themselves, they're presented as a challenge-centric game, rather than a dry academic exercise. This gamification approach offers helpful guidance to ensure you don't actually 'lose'. Instead, you'll progress through a series of learning opportunities.
To ensure everyone stays on board, the first lessons follow a pretty gentle learning curve. It starts with some basic code instructions or making simple edits to existing code. Along the way, you'll be asked to solve a number of challenges and puzzles, such as writing instructions to find a hidden object.
For example, in 'Learn to Code 1' you'll be challenged to guide the Byte character through a series of fantasy puzzle worlds. These tile-based worlds are populated with items such as gems, switches and portals. Byte can interact with these items, once given the appropriate coded commands.
Short animations introduce new coding concepts before you dive in, and at this intro-level, hints to problem solutions are also available. But you can't just copy and paste hint code snippets. Instead, you'll have to type in the code, because by typing code you're far more likely to recall the coding solution at a future time.
Download 'Learn to Code 2', and you'll be presented with more advanced concepts such as arrays and object-oriented programming concepts. At this stage, it's also possible to extend and manipulate the puzzle world itself. However, this time there are no hints, so you'll be on your own when solving the puzzles.
Despite the gentle start, by the end of the second tutorial you'll be familiar with commands, loops, parameters, conditional code, variables, operators and types. You'll also be able to create your own functions, such as one called 'twoStepsForwardTurnAround()', or define new functions composed of other functions. More advanced concepts like code debugging are introduced gradually to maintain clarity.
It's worth stating that Swift Playgrounds offers extensive full access to the device's hardware. This includes the accelerometer and other built-in sensors, multi-touch, the camera and wireless communications via Bluetooth.
In fact, there's full access to existing iOS frameworks, such as SpriteKit for 2D games, SceneKit for 3D graphics, WebKit for Safari interaction and UIKit for desktop stuff.
Entering Code
In development mode, the screen is divided into two halves. The left-hand side is where instructions appear and code is entered, while the right-hand side is dominated by the Live View runtime display that responds to the running code.
With a classic editor, every statement is entered character by character. But here things are very different. Instead, you'll see a dynamically presented selection of context-sensitive keywords. These pop up above the keyboard and let you quickly and easily tap out commands and functions. Scroll through these horizontally to uncover the full suggestion list.
Most importantly, when considering the generation Apple is targeting, Swift Playgrounds delivers a tactile coding experience. Here you can actually touch the code. Tap variables to set a value (say, a colour via a pop-up colour picker), or change the code execution sequence by dragging code blocks around, such as a loop with all its inner code statements.
Essentially, the whole coding experience is highly interactive. For example, you can jump in and start typing new code when your previous code is still running, then hit the 'run' button to restart program execution from the beginning using the new edits.
This touch interface means anyone can dive straight in and start to play. Yet using a physical keyboard does have its advantages. Apple has tweaked the standard iOS software keyboard to be more code friendly. Each key has one or two swipeable alternate characters - for example, a diagonal swipe imitates a shift key action. You can still copy-cut-paste in the usual manner, and you'll still see the suggestions list at the bottom of the screen.
When it comes to those inevitable typos, like a mistyped function name or invalid punctuation, a small red dot appears next to the lines with syntax errors. Each dot has an associated hint text message, which may or may not be illuminating, as we'll see later.
Learn And Share
Apple is very aware many teachers and parents have little or no experience of writing code. They need just as much help as the students to get to grips with the app and all its possibilities. Fortunately, Apple provides plenty of assistance.
Firstly, there's an in-app quick reference for basic information, plus a glossary of coding terms. There are also a few books. Two of the most notable are the 'Swift Playgrounds Teacher Guide' and 'App Development with Swift', the latter designed to bridge the gap between Swift Playgrounds on iOS and writing apps with Xcode on macOS.
Sharing your code is an important feature too, especially in a classroom environment. As you might expect, you can share code via Mail, Messages or AirDrop, but there are a few other interesting options.
You could record a video of yourself coding or running your program, complete with your own voice narration. This could be a useful teaching aid, and you can even broadcast a coding session live to the world via a streaming service app that supports Apple's ReplayKit.
Room To Improve
It is of course early days for the Swift Playgrounds initiative. Nevertheless, it's still worth mentioning some limitations and areas where the coding experience could be improved.
The biggest limitation is that while you have access to lots of iOS app functionality, you can't make real App Store apps with Swift Playgrounds on an iPad. Yes, you can export playgrounds into Xcode 8, but to run Xcode you'll need to use a reasonably powerful Apple macOS desktop or laptop, which is a significant hardware investment, and moving to Xcode is itself a big leap.
Even if you do go down this Xcode app-building path, to distribute your app on the AppStore, you'll need a $99 yearly subscription to the Apple Developer Program, even if your app ends up in the 'free to download' category.
In terms of improvements, it would be helpful to see some sort of visual relationship between the lines of code and what's actually happening on the screen - especially when the program has a hierarchy of functions calling other functions.
As we mentioned earlier, small red dots appear next to lines with typos and other syntactical errors. This is fine, but the hints hidden behind those red dots aren't always easy to understand. For example, would you know what 'use of unresolved identifier' means? In fact, the language used in these hints is pretty much what you'd expect to hear in a discussion between professional developers.
Just A Start
The good news is that Apple has already stated its intention to expand on this first incarnation of Swift Playgrounds. However, as usual, Apple isn't being particularly forthcoming about what's actually going to happen and when, and initial feedback from users and the education community will no doubt be analysed before final decisions are made.
At the time of the official rollout, there were two 'Learn to Code' lessons, but we can expect to see more advanced Playgrounds lesson packs that showcase the app's versatility and potential. After all, there's scope to do much more with the iPad's camera, built-in sensors and so on.
We can also expect a steady stream of new coding challenges to appear over the coming months. These challenges are likely to introduce new topics and themes to ensure coders stay engaged and, as any experienced programmer already knows, there's always more than one way to solve a problem with code.
One initiative that's grabbed many people's attention is the ability of Swift Playgrounds to control the Star Wars BB-8-like Sphero SPRK+ robot. First demonstrated on stage at this year's Apple Developer Conference event (deveIoper.appIe.com/swift/bIog/?id=38), there's now a fresh update of the software.
As we mentioned already, this isn't a tool for creating real apps. Instead, Apple's design focus is on teaching key coding concepts, but remember, you do get to play with real Swift code rather than some language that's not actually used for 'real' software development.
And yet, this real app creation limitation could be overcome by the introduction of an iPad-compatible version of Xcode, plus a student-friendly Apple Developer Program subscription. Apple isn't ready to confirm whether this might happen just yet.
Shows Promise
Overall, this initial release of Swift Playgrounds holds plenty of promise. The target may be tech-savvy secondary-school children, but it's just as applicable to anyone who'd like to get to grips with the fundamentals of good coding practice, regardless of the age group they fall in.
Coding newbies and those with limited experience (say, through creating HTML and CSS web pages) will appreciate the steady pace of the lessons, and this is certainly a far more gentle journey than diving straight into Xcode.
Apple is bullish about the success of Swift Playgrounds app. As senior vice president of software engineering Craig Federighi said, "More than 100 schools around the world have already committed to adding Swift Playgrounds to their fall curriculum, and we can't wait to see what students create with it."
Objective-С Language
In 1997, after reinstating the deposed Steve Jobs, Apple acquired the NeXT company, an organisation he founded after being forced out of Apple. Shortly after, the NeXTSTEP operating system became the foundation for the then-new Mac OS X and iOS operating systems.
As the Objective-С language was the core development language of the NeXTSTEP operating system, it consequently became the de facto standard for all Apple system and app development from that point forward.
As the name suggests, Objective-С and its close relative Objective-C+ are object-oriented software languages. The basic syntax has a lot in common with the С and C++ languages, but there are also a number of unique and rather idiosyncratic additions, and these additions can take a little getting use to, even for long-standing professional С and C++ developers.
Apple Swift Language
In may ways Swift is a much needed replacement for Objective-С. It has a simpler syntax and solves numerous flexibility and performance roadblocks faced by Objective-С developers. Yet it's more evolutionary than revolutionary, with support for many core Objective-C concepts, such as dynamic dispatch late binding and the extensible programming model.
All this means it wasn't too difficult for existing Objective-С developers to migrate to this new language. However, it does mean Apple missed out on the opportunity to create a more open, standards-based language that could engage non-Apple coders and help expand the existing Apple development community.
Swift started life as another Apple-only proprietary language that locks developers into the Apple platform. But since version 2.2, it has become an open-source language as defined by the Apache License version 2.0.
Swift is the future of Apple development and is definitely here to stay. It is really the only choice if you want to develop apps for macOS, iOS, watchOS or tvOS using the latest Apple-provided libraries and tools.
Xcode
Xcode is a free-to-download Integrated Development Environment (IDE) built from a suite of development tools and software libraries. Using Xcode, developers can build system tools or apps for macOS, iOS, WatchOS and tvOS.
First appearing in 2003, it's refreshed every year to support Apple's yearly operating systems updates, or new additions to the operating system family like watchOS. While the primary goal was to support the Objective-С and Objective-C+ languages, source code support extends to C, C++, Java, Python, Ruby, AppleScript and ResEdit.
Xcode can build what Apple calls 'universal binary' executable files. These executables can run on the old Apple PowerPC hardware as well as the Intel x86-based architecture used for today's range of desktops and laptops. Xcode can also compile and debug applications for the ARM chips, which are inside iPhones, iPads, Apple Watches and Apple TV boxes.
Xcode version 6, released at the Apple Developer Conference in June 2014, included a new live and interactive code/test/debug environment called Playgrounds, plus a new development language called Swift. The latest stable release is version 8.