About a month ago, Apple dropped a bomb on the development community (in a good way) introducing their brand new language for developing iOS and OSX apps called Swift. They talked about how modern the syntax is in comparison to Objective-C (which I personally love). How safe it is for developers with strict typing, type inference and optionals. And how powerful it is with constants and 2 different collection types. It’s an amazing language, and I’m enjoying learning the ins and outs of it as fast as I can.
In addition to the language, Apple also introduced Playgrounds, a way to write Swift code, and have it compile as you type. You can then see the results on the right side, monitor value changes and even graph out those changes from a loop. This is night and day different from what Apple developers have been used to. In the past, you would write code, hit compile and cross your fingers. Now that you can see the results as you code, the idea of play is finally possible within Xcode.
Image via Apple.com
Playgrounds are amazing, and I highly recommend everyone trying them out, but there is a feature in Playgrounds that wasn’t mentioned (or I missed it) in the keynote, you can actually open documentation and even the Swift tour within a Playground. Follow these steps for the tour:
Open Xcode.
Select Help from the menu, and type in “tour”.
When you see “A Swift Tour”, click on it.
In the documentation, near the top, there is a link that says “Open Playground”. Click it.
Now the entire Swift Tour is running with a Playground. You can see the documentation inline with the code examples. Those code examples are compiling, and you can see their values on the right side. Even better, you can manipulate the code and see those results as you make changes (the tour actually encourages it with Experiment markers under different sections.)
This is crazy awesome! It combines the depth of knowledge a book has, with the interactivity and room for play places like Code School have. It is one of the most powerful things I’ve seen in a while, and makes on-boarding a new language, or even just learning programming for the first time, so much easier. I can’t wait to see more documentation work this way, not just from Apple, but from people making frameworks and other code to work with Swift in Xcode. Coding for iOS and OSX is finally fun!