hypepat

by PAT GAFFNEY

Learning Swift

I started working through Apple’s The Swift Programming Language about a month ago, and I fell into a groove with Swift almost immediately. Writing Swift feels familiar — almost like I’m writing in some intermediate language between C and Python.

I have zero experience writing Objective-C, so I’ll avoid making direct comparisons. What I will say is Swift reads a hell of a whole lot better than Objective-C. Sometimes I end up using Github like StumbleUpon 1 and I find myself staring at a 3,000 line Objective-C file. The whole goddamn thing is covered in square brackets, and there are seemingly random references to id everywhere. I’ve never been more terrified in my life.

Swift reads very cleanly — almost like pseudocode. I have spent the last few weekends with this brand new language, and I’m confident I could stumble my way through someone else’s code at this point. Comparatively, disregarding my feelings for bracketed markup, I feel lost when I read Objective-C. 2

I love the idea of getting in on the ground floor of something — potentially shaping the idioms that come out of this community in the next few years. When I started learning Python, this was the biggest struggle for me. I had rather basic experience in C and Java, and it seemed like there were all these gotchas to writing Python code. Somehow everyone knew the ins-and-outs of for-in loops, and I’m over here writing index variables. Later I realized there was a pythonic way of doing things. Swift doesn’t really have this yet, and so far it seems like one of those good problems to have.


  1. What ever happened to StumbleUpon? Days (probably weeks) of my life were wasted hitting the stumble button and staring blankly at the screen. More cat pics? Ice cubes that look like Hitler? Someone made a mashup of the Cheers theme song and Yeezus? 

  2. I have tried to force myself to get into Objective-C a few different times now, but it never took. It feels like an ancient language. I usually get an hour into some tutorial or walkthrough and next thing I’m looking up [bridges for Ruby][macruby]. I’m a student of the [University of Siracusa][copeland], and I feel like I should be afforded some memory protection.