A Detour Through Swift

A programmer who returns to dabble in iOS development every few months could be likened to a modern day, overly dramatic Sisyphus, reaching a near breakthrough at the top, only to be defeated by diminishing time or by waning willpower. In the common day vernacular, “it me.” (I regret this.) This time, however, the usual trodden path has been foregone for a scenic route with Swift.

In the early days, the first learning curve was Objective-C, similar enough to C but also alien with its bracket and colon-heavy (more regret) syntax. Learning memory management and understanding protocols followed suit. I just wanted to put a button in a view, dammit.

Coupled with that was learning to wield XCode, both before and after it was assimilated with the iTunes Borg. To this day, I’m still unsure where the line is drawn between the code one writes and Interface Builder where one has to click-drag a bunch of things to other things. Storyboards? I can only imagine they’re frames of my failing to program in iOS. Roll credits.

And thus, we have Swift.

As with any language, there’s bound to be new syntactical patterns to learn. My brain divides languages up into two camps: Compiled, statically typed, Algol derivatives such as Java or C/C++, and Interpreted, dynamically typed, quick-to-write, slower-to-run languages such as Ruby or Python. The former is Serious Business, Tuxedo After Six. The latter is Atypical Web Dev in $conference t-shirt and jeans. (We may ignore the terrible Bash scripts that I’ve wrought upon the world, which is Gremlin Who Lives in Basement Next to the Fuse Box.)

That’s why years ago, Go broke my brain with its wacky, mutant syntax. Braces, but no parentheses around your conditional? That’s a Tuxedo t-shirt. I understand what you’re doing, but I’m going to furrow my brow and shake my head.

Having endured the hardships of that transition, I find Swift syntax to be more palatable now. Languages like Go, Rust and Scala have different concepts and well, punctuation, than what I’ve worked with for the first fifteen years of programming. Now I don’t blink twice when I see Tuxedo t-shirts.

I’d like to think my steadfast inclination towards particular syntax is less about pedantry and more about breaking down the barrier between my eyeballs seeing a bunch of glyphs and my brain understanding the concepts behind the code. That’s why we have indentation. That’s why I like to adhere to 80 columns so I don’t have to scan horizontally. THIS IS WHY YOU ALWAYS LEAVE A NOTE! (in the form of succinct comments describing an otherwise enigmatic expression).

So far Swift seems much easier to read than Objective-C, but as a novice in both languages, with enough practice I’m sure it could go either way.

The scenic part of this route is due to Swift’s commitment of having documentation and ecosystem support as first class citizens. It must have been a lot of hard work making sure that, for example, it was just as easy to see a method signature in Swift as it is in Objective-C. Sure, you can probably do the translation in your head, but that’s just more thinking to do, and I only got about fifty brain cycles a day. Sixty, on a good day.

In the documentation, from a beginner’s perspective, Swift might have been here all alongside Objective-C. Maybe that’s how it is in the Berenstein Bears Universe. Maybe I’m a better writer in that universe.

XCode is tremendous in being able to be productive in Swift. As much as I’d love to channel my inner Donald Knuth by sitting down and typing all the correct code from beginning to end in my text editor of choice, being able to get feedback from one’s IDE in realtime in a statically-typed language really helps productivity and accelerates the learning process. This isn’t a new concept by any means, but it’s always nice to have quick feedback while learning a new language. In this spirit, the Playground feature looks really interesting.

It remains to be seen how this iteration of boulder-pushing will go, but already I’ve picked up a few souvenirs along the way. Type inference really is cool, even in languages and in IDEs other than the ones I’m used to. The thought that we are rich with CPU cycles and a computer can analyze and compile and tell you “yes it is deterministically impossible for this line to work, go fix it dummy” still amazes me. Decades ago we were using punchcards. That feedback loop sucked.

Another minor, but surprisingly interesting concept is when you treat constants and variables as peers, I think it levels the playing field for immutability, which I bet unlocks a bunch of cool things and optimizations. Whereas in other languages, naming constants BIG_MAGIC_THING or using keywords like “final” or “const” seem aloof and inaccessible in comparison to Swift’s “let.” It’s probably short for “let’s be friends!” (Last regret.)

Finally, my most prized souvenir of all: no matter what happens, there’s a corner of my watch that says a thing. It’s actually the wrong thing today (it was correct yesterday) but the point is, I put that thing there. By typing and clicking and failing and flailing and unplugging and plugging and resyncing and compiling.

And that’s why we boulder pushers push boulders.

Like what you read? Give Jerry Chen a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.