First Impressions of Swift

Ohio was hammered with snow last night, leaving me with a snow day today. After spending an hour shoveling myself out of the driveway (which I expect I’ll have to do again to get back in), I headed to Starbucks, grabbed a coffee, and decided to look into the current state of iOS app development.

I’ve dabbled in Mac/iOS development in the past, but I’ve never made the time to build anything significant/useful. This might relate to my opinion that writing code in Objective C wasn’t really fun. I get a thrill out of writing clean Python code that works well, whereas Objective C just kind of felt a little too raw and nit-picky. I frankly don’t want to have to worry about memory management, and “NS” everywhere just seemed like unnecessary typing and clutter.

I had heard of Swift, but didn’t really know what it involved or how it was different from Objective C development. All I knew was that it was an iOS 8/Yosemite-focused language, and that it was Apple’s new thing.

Coffee in hand, I downloaded the latest version of Xcode from the app store, and started reading about Swift. And my first impression was that it reminded me a lot of Python.

Imagine my delight at seeing first-class support for dictionaries and lists and strings without any workarounds. The code was so clean! No unnecessary brackets around every single object! No semicolons necessary! No parentheses required around if conditions! For-in syntax! Native string interpolation! Native tuples!

Plus, it has some features that Python doesn’t have yet, such as static type checking. And the syntax is even similar!

Another great feature that warmed the cockles of my heart is the idea of playgrounds. I find it very useful in Python to be able to fire up an interpreter and do real-time coding. Playgrounds takes that even further to make live debugging a natural part of programming. You get to see the result of every line of code in a little sidebar next to your code, no compilation necessary, making it really easy to experiment and identify where issues might be.

In short, Swift seems to bring the joy of Python programming to iOS/OSX development, without suffering from the performance hit that bundling a Python interpreter with an app entails. Stay tuned for a post detailing my experiences building a simple app!

(Note: If you’re looking for a practical, hands-on introduction to Swift, and you have some programming experience, I highly recommend downloading the playground associated with the Swift Tour from Apple. It’s hands-on, and it’s cool to see how everything works step-by-step.)

Leave a Reply