Swift Playgrounds is my favorite thing to come out of this year’s WWDC by far, and I think it’s going to be one of the highlights of iOS 10 when it’s released this fall.

Swift Playgrounds is a revolutionary new app for iPad that makes learning Swift interactive and fun. Solve puzzles to master the basics using Swift — a powerful programming language created by Apple and used by the pros to build many of today’s most popular apps. Then take on a series of challenges and step up to more advanced creations. Swift Playgrounds requires no coding knowledge, so it’s perfect for students just starting out. It also provides a unique way for seasoned developers to quickly bring ideas to life. And because it’s built to take full advantage of iPad, it’s a first-of-its-kind learning experience.

Everyone Can Code

Technology has a language. It’s called code. And we believe coding is an essential skill. Learning to code teaches you how to solve problems and work together in creative ways. And it helps you build apps that bring your ideas to life. We think everyone should have the opportunity to create something that can change the world. So we’ve designed a new approach to coding that lets anyone learn, write, and teach it.

Take things to Xcode.
Then take them further.

Because you’re working with real code, you can import and export directly between Swift Playgrounds and Xcode. So you can try out your ideas with the tool pros use to develop iOS and Mac apps.

Finding lessons

When you fire it up, you’ll see a Featured section with lesson packs named Learn to Code 1: Fundamentals of Swift, and then Learn to Code 2: Beyond the Basics. Below that are the Challenges, starting with Drawing Sounds and Blink. More lesson packs and challenges will be added over time, and the lessons are RSS-based, so Apple can add new content without having to update the app itself.

Downloading a lesson pack or challenge adds it to the My Playgrounds tab, which looks like the shelf in iBooks. You can create new playgrounds too, or download them from other sources. For example, Apple made a Sphero playground to demo at WWDC, showing how Swift Playgrounds can use all of the iPad’s hardware and software features, in this case connecting via Bluetooth and issuing commands to a Sphero robotic ball. Sphero could actually make its own playground and distribute it on its own site, explained Wiley Hodges, Apple’s director of tools and technologies product marketing.

From this shelf, you can also duplicate a playground or reset it. Say your child is halfway through a lesson her little sister wants to try, too. You can duplicate the playground to make a copy, then reset the copy to its original state. (Swift Playgrounds will also work with the classroom-management features Apple added for teachers in iOS 9.3.)

 

Swift Playgrounds encourages creative problem-solving—there isn’t one single solution, or even one “best” solution. You aren’t graded on how few lines you can use or how many functions you come up with. But the app does teach good coding habits like looking for patterns that repeat, and using descriptive names for functions so you can more easily remember what they do. If you break out ahead, say, adding a loop to your code before you are formally taught loops, the app gives you props for your advanced skills.

The benefits of Swift is that it’s fast and powerful like compiled languages like Objective-C, while also being more friendly and easy to read like a scriping language. Commands and functions are built with human-readable words. My first encounter with writing code was back in the ’80s, when I learned BASIC at a summer day camp for nerdy children, and I loved how I could tell what it was going to do before I actually ran it, just by reading the code. Swift reminds me of that, and Swift Playgrounds’ splitscreen view makes that visualization even easier, the code listed on the left, next to the virtual world where it’ll run.

In fact, Swift Playgrounds is (naturally) written in Swift, and the code you create in the code editor is inserted directly into the program running on the right side of the screen. Once I accidentally deleted a bracket and broke the code. It wasn’t a problem of the onscreen Byte character not reaching his goal because I’d given him the wrong commands and sent him in the wrong direction. He wouldn’t move at all until I fixed the syntax, an in-my-face reminder that every keystroke matters. The game world uses SceneKit, Metal, and 3D acceleration, the same technologies used all over iOS.

swift-playgrounds-ios10-characters-100671813-orig

Swift Playgrounds is available with the iOS 10 public beta, including Learn to Code 1 and two Challenges. More lessons will come later with the final shipping version of the app, launching with iOS 10 this fall.