As a part of my Summer’s Goal List, I have decided to learn Swift for iOS. Swift is Apple’s relatively new programming language, optimized for iOS and OS X development. Through figuring out ways to accomplish learning Swift, I found that learning Swift’s library was my best bet at learning the new language in a way that would not leave me frustrated. Every tutorial that I have come across seems to assume that Swift is their target audience’s first programming language. Sitting through the painstakingly frustrating explanations of what a loop is has lead me to realize that reading Swift’s API is probably my only way of learning Swift for the time being.
Xcode’s playground mode makes learning Swift’s library a breeze
Before I get into Xcode’s playground mode, I want to talk a bit about my experience with using Xcode in general. When I first started to learn C++, my professor wanted us to use Visual Studio so that his students were all using the same IDE. This made troubleshooting issues a bit easier because we were all using the same environment to code in. I quickly fell in love with Visual Studio’s robust features and used it for all of my C++ projects. However, recently Microsoft’s student developer system fails to validate that I’m a student, so I recently switched to Xcode for C++. I found Xcode to be really helpful in learning OpenGL + GLUT and Xcode began to grow on me. Whenever I used Xcode and created a new project, I would always see “playground” as a file type option and never really understood the difference between a playground file and a project file. I’d even did a web search and just as I suspected, the playground mode was a way to practice one of the Xcode’s supported languages in a rapid manner.
In playground mode, you can type your code, Xcode validates the syntax and puts the output immediately to the right of where you’re typing. This allows you to practice code without having to build and run as you go. I have been able to go through the Swift tutorial book rapidly while practicing and executing the tutorial’s “experiments” in order to gain additional understanding of the syntax. This has been greatly beneficial and what’s cooler is that I am able to use comments to organize my code with key words so that I can use my own playground as my own personal API for when I start to develop using Swift. I’ve done this while practicing other programming languages, but using the playground functionality makes what happening within the code, abundantly clear. As simple as this functionality is, I can’t imagine that Xcode is the only tool out there with this functionality, but this is my first experience with technology like it and I’ve been extremely pleased with the results thus far.
Here’s a screenshot of a snippet of the playground that I’ve been using for learning Swift:
Overall, I’m really happy that tools such as these exist. Having the ability to rapidly see the output of my code as I practice and type out the tutorials, have really made learning faster and more rewarding than waiting to rebuild and run code in chunks in order to text functionality.