I will miss you, Objective-C

Daniel Lozano Valdés
Sudo by Icalia Labs
3 min readOct 3, 2015

If you’ve read anything on iOS or mobile development lately you’ve probably heard of Swift, Apple’s cool new programing language. It’s a modern language created by borrowing ideas from several languages like Javascript, Ruby, Python, C#, and Java. It’s a type safe, fast, compiled language created for developing on Apple platforms (iOS, WatchOS, TVOS, & MacOSX). And, as was announced at the last WWDC, it will soon be Open Source with an official SDK available for Linux.

So what’s so cool about Swift? Well, there are lot’s of things I could not possibly cover in a short blog post but I’ll gloss over a couple of them.

  • Its type safe, so you generally no longer have to worry about checking what type of variable you have.
  • It has a strong optional syntax, in which values that could ever be NULL must be explicitly defined as so. So no more checking for null, instead you have a logical easy to understand way of “unwrapping” optional values.
  • You can have Protocols which are like Java interfaces, but since Swift 2.0 are much more powerful because they can be extended with a default implementation and can be used as Traits or Mixins in which you can add features to existing classes without inheritance which can sometimes be messy. This is called Protocol Oriented Programming and it’s going to be huge.

All that said I had no problem at all with Objective-C, which is the old (32 year old) language in which all of Apple’s platforms were built on. Yeah, it’s pretty old, it was originally built by Stepstone then bought and advanced by NextSTEP the company created by Steve Jobs while he was on sabbatical (fired) from Apple, which later on was bought by Apple and its technologies (OS-X, Cocoa Frameworks, and Objective-C language) became the basis for everything Apple from then on.

Objective-C was the love child of Smalltalk and C. It had a [weird] (yeah, brackets everywhere) syntax that scared many people away, but once you got to knowing it, you fell in love. It was centered around the concept of Message Passing (i.e. Smalltalk), so it was an extremely dynamic language.

I grew to love the obscenely long method names with the variables inside of the method (they read like sentences!). I even loved the square brackets (what a perfect visual metaphor for sending a message- they’re the envelope!). I learned the intricacies of the Objective-C runtime and the Foundation frameworks. I was swizzling and introspecting in ways I never thought possible. — Luke Deniston

It was verbose:

- (id)initWithBitmapDataPlanes:(unsigned char **)planes 
pixelsWide:(NSInteger)width
pixelsHigh:(NSInteger)height
bitsPerSample:(NSInteger)bps
samplesPerPixel:(NSInteger)spp
hasAlpha:(BOOL)alpha
isPlanar:(BOOL)isPlanar
colorSpaceName:(NSString *)colorSpaceName
bitmapFormat:(NSBitmapFormat)bitmapFormat
bytesPerRow:(NSInteger)rowBytes
bitsPerPixel:(NSInteger)pixelBits;

Yeah, thats a method name, woops. But in that extreme verbosity you had awesome, readable and easy to understand code, and since X-Code’s autocomplete is pretty quick your fingers were OK.

You could dig in to the Objective-C runtime and do awesome dynamic stuff, like meta-programming, which is necessary for some frameworks to function (like my favorite by Github, Mantle). Unfortunately that’s no longer easilly doable in Swift.

But, it’s time to move on and grow up. Yeah, Swift is not as dynamic as Objective-C but you trade that in for a bunch of other more important things. It’s cleaner, faster, safer, etc… I was reluctant to try it out at first in any serious app since it was so new and changing so often. But I think now is a good time to move on since Swift 2.0 is out, and I have a feeling it’s going to be a lot more stable from now on.

Objective-C will always be special for me. It was the first and only language I really learned completely inside and out. It taught me lots of things, and made me a better software engineer, altough some of that is thanks to the Cocoa Frameworks which are mostly pretty well done. Although it probably will never happen, I really hope Obj-C is open-sourced so it does not completely die off so I can still use it for any odd thing whenever I’m feeling nostalgic and bored and have nothing beter to do.

[goodbye objectiveC];

Daniel Lozano
iOS Developer @icalialabs.
Web: http://danielozano.com ; Twitter: @danlozanov

--

--