Thoughts on Swift Playgrounds

At WWDC 2016 Apple announced Swift Playgrounds for iOS. Swift Playgrounds is an app that is connected to a larger initiative from Apple called "Everyone Can Code".

Everyone Can Code comprises the Swift Playgrounds app itself, a series of teacher and student guide books on the iBookstore and a suite of curriculum content delivered inside the Swift Playgrounds app.

I've spend the past few days at WWDC getting up to speed on Playgrounds and here is my first-cut at understanding how it all fits together.

The App

Playgrounds is genuinely a full Swift interpreter built into an iPad app. Although the demo in the Keynote focused on some simple concepts, it's not a toy or limited version of the language.

The app is comprised of two parts: the source view on the left and the live view on the right. The source view is where you type your program and the live view is where you see any output. At the same time, in the right margin of the editor, you can see intermediate results as they are calculated. This has been part of Swift Playgrounds on macOS for some time.

The app supports two kinds of files. The first is the Playground file that you can create using Xcode on a Mac. These files can be transferred to the iPad and run as-is inside Playgrounds on iOS.

The second kind of file is called a Playground Book. This is what you saw in the keynote. It's much richer and supports a nested chapter and page structure that supports navigation as well as basic assessments of success inside each page. The package format is documented online.

There are also a range of things that authors can do with each page in a Playground Book to make it easier for beginning programmers to meet success. These include hiding setup code that doesn't need to be seen by the learner, defining "editable regions" to constrain the learner to only type in certain areas and providing hint text in those editable areas.

Another feature of the app is that it freely allows import and export of Playgrounds and Books to other users via AirDrop. In my teaching experience with beginner programming environments, being able to inspect and adapt someone else's code is a very good way to build learners' curiosity and confidence - as well as a bit of competitiveness!

The app also features certain other simplifying tools for entering code. There are colour pickers, image literals and other gestures that make it easier for learners to avoid syntax errors. One simple example is that you can drag out the lower brace of a conditional statement or loop to enclose other statements and everything springs into place when you let go.

The QuickType bar above the keyboard (the area where you get text suggestions) has also been adapted to give code completion suggestions that are sensitive to the context and only let you complete legal code in the language. Authors of Playground Books can also give hints to the suggestions mechanism to constrain it to only show certain symbols or only symbols from certain packages.

It's important - and not at all obvious on first sight - to understand that Playgrounds is not in itself an authoring environment for Playground Books. When a learner works with a Playground Book, their edits to the code in the book are stored as a diff against the original content in the book. The original content is never modified, but the diffs do get transferred with the book when it's sent to other users. The reason it's done this way is that it facilitates resetting a page in the book to its original state if the user needs to. You can also reset the entire book.

The other thing that is not entirely obvious is that Playgrounds has full access to the entire iOS API. This means that there is effectively no limit on the complexity of Playground that you can build. You can use APIs like Core Location, WebKit, MapKit, Core Motion, Networking and Core Bluetooth. One of the demos given in the session on Playgrounds was of Playground Swift code controlling a Sphero robot over Bluetooth. I already did the standard daft Browser-in-five-lines-of-code trick that we used to do on the Mac.

The Swift Language

A broader question than "is the app any good?" is whether or not the Swift language itself is any good for Computer Science education. I have in my career taught children to program in Visual Basic, Ruby and Most recently Python.

As a Computer Science teacher, I need to know that Swift is a good language for learning to program with. One simplistic approach to promoting Swift in CS is simply to make the argument that kids love smartphones and apps are written in Swift therefore CS education should happen in Swift. I get the thinking behind that but it feels as zeitgeisty as the other moves that teachers make to co-opt anything that kids like and turn it into "education". Remember Second Life? And .... dare I say it .... Minecraft In the fullness of time?

I prefer to ask which specific language features in Swift make the language a good choice for learners. I challenged Apple staff this week to make that case and I came away with some good points. One of the things I particularly liked was that Swift leans toward explicitness rather than implicit or inferred behaviours.

Swift also has API design guidelines focused on expressiveness and understandability rather than terseness. It's also a relatively new language. This certainly has its drawbacks in that the language has changed substantially over the last two major revisions but there is a consistency and clarity to its approach that is sometimes missing from languages like Python.

What's Not to Like?

Swift Playgrounds is a very new app on iOS. Although it's fairly complete, there are a few things I feel that it still needs.

Firstly, I mentioned that there are ways to get the Playgrounds app to render your code by omitting and hinting certain areas. There's currently no way to get that rendered view out of the app. This is important for teaching in two ways: firstly, it would allow students to submit work to a teacher through iTunes U. The second reason is that a teacher authoring a solution would be able to give a printout of a completed (rendered) version to a pupil who needed it for whatever reason - perhaps a pupil with learning difficulties for whom copying in a provided solution would represent a good achievement. Giving these pupils the full unrendered source would be overwhelming.

The bigger issue right now is that the authoring environment for Playground Books is Xcode on macOS. I'll invite you to use the fingers of maybe both hands to count the number of teachers in your area who (a) even have a Mac and (b) are au fait with Xcode.

I have seen many times that any time the phrase "you use a Mac for that" is a total and complete show-stopper in education. This was true for iTunes U before Course Manager came to iOS and it's still true for iBooks Author.

I think there might, in time, be ways to create Playgrounds and Playground Books on iOS but it will be neither easy nor convenient for some time to come. This isn't an unexpected problem but it is still a problem.

Overall, though, it's hard to find anything seriously bad to say about Swift Playgrounds except that it's an early, immature product right now. Despite that, it already has serious power under the hood and some impressive curriculum content. Can't wait to see where this goes.

New Project: iPads for India

I'm starting a new short-term project to raise money to send iPads to the Barefoot College in India.

A friend recently asked me if we had any iPads that we could donate to the project he's working with in India. We didn't actually have any right then but we are coming up to the end of our lease at school and I thought there might be an opportunity.

Our lease requires that we either send the iPads back to the leasing company or buy the lease out. To buy out, we would need to pay back the fair market value of the iPads, which is currently about £100 per unit and we have 110.

I spoke to our leasing company and they generously offered a cut in the buyout price to support my plan and my intention is to try and crowd-fund the rest of the money from people who read this blog, listen to my podcasts and follow me on Twitter.

I really want to make this work as delivering 110 currently-supported iPads to a project like Barefoot College will make a huge difference instead of having to rely on older, unsupported and unreliable hardware.

Barefoot College

Barefoot College, which was recently visited by Apple VP Lisa Jackson, is an organisation that trains women in rural India to build solar powered projects to help their villages. These projects include solar water heating, cooking, desalination and even data projectors for use in night schools.

How to Help

As I said earlier, the main goal of my project is to raise enough money to buy out our school's equipment lease and own the iPads. I will then be working with Barefoot College to repair, test, configure and transport them to India. My friend, with my remote help via Skype, will be managing the iPads at Barefoot College. He is already doing this for the smaller number of devices that they currently have.

If we over-shoot the funding goal, we will use the money to either buy other equipment that will help the Barefoot College mission (USB hubs, spare cables, chargers, etc) or we will donate the surplus directly to Barefoot College.

If we don't make the target, Barefoot College will receive all donations.

Make a Donation at Crowdfunder.co.uk

Making a donation is the best support but I would really appreciate it if you could share this project with your friends social networks. Linking to the Crowdfunder page would be the most direct route for people to help.

I need to raise £180 per day to get this project done - will you help out?

Canvas 11 - Travelling with iOS

Canvas is a podcast all about iOS productivity that I co-host with Federico Viticci. This week Federico and I discuss travelling with iOS devices.

With summer - and WWDC - coming up, Federico and I bring you advice on the equipment, apps and tweaks for your iOS devices that you need when travelling with your iOS devices.

The travel bags are opened to reveal the essentials within. Federico and I share our favourite travel accessories, techniques for getting online abroad and our preferred iOS settings tweaks and Apple Watch complications for having fun and staying safe abroad.

A range of useful links are below.

Subscribe

You can subscribe on iTunes, in Overcast or at Relay.fm. If you love the show, you can support it by becoming a member at Relay.fm.

Featured Travel Kit

Featured Accessories

Featured Apps

Featured Travel Tips

Out of School 180: Apple School Manager Hands On

This week on Out of School Bradley and I discuss the Apple education events that have been held in various areas to promote the new education features in iOS 9.3. Bradley held one such event in his school recently.

We, of course, continue to track the varying responses from Apple staff on whether Managed Apple IDs will get more free iCloud storage. At this point, I feel like anything less than unlimited iCloud for students will be seen as maddeningly parsimonious on Apple's part. We live in a world where companies are lining up to throw free cloud storage at schools - it's one reason why we love Google Apps at Cedars - and for Apple to cheap out on this would, in my opinion, be a mistake.

Bradley also got his first live demo of Apple Classroom and I report on some experiences having used it in school for the past few weeks.

iOS 9.3 Events

Thanks, as always, to our Patreon supporters. If the show helps you in your day to day work, would you consider supporting us with a monthly donation?

You can: