In praise of Objective-C

It is tough to write anything about Apple without being accused of fanboism, however I really do admire Objective-C. Originally created at Stepstone it has become synonymous with Apple's platforms, and I believe it leads the pack of general purpose programming languages. This is not something I feel with the fervour of a Lisper defending his or her parentheses, but Objective-C occupies a market leading middleground between the performance centric C++ and the programmer focussed Java.

Java's early press focussed on its portability, "Write once, run anywhere" was the promise, and it seemed enough to make Java the programming language of the internet. It wasn't sufficient; javascript "won", but Java lived on as a general purpose language. Java's designers had realised that programmer time was more valuable than CPU time and they endowed their new language with a vast standard library and runtime features such as garbage collection. This approach stuck, and languages are now judged as much by their package manager, integrated documentation and ecosystem as they are by the syntactic choices of the designers.

Unfortunately, Java's designers didn't seem to value CPU time at all. The language has a nasty reputation for sluggish interfaces, and its execution speed drags well behind C++'s. Pointer aliasing or not we are many generations of optimisers away from languages such as Java overtaking C++ so if you need fast code C/C++ is the obvious choice. As a strict superset of C you can add Objective-C to that list.

Objective-C's triumph is that although it shares C++'s efficiency, Cocoa, its standard library, rivals and sometimes exceeds the libraries available for .Net or the JVM platforms. Objective-C saves you from making the choice between the high-performance C++ or the programmer-friendly Java by adding a substantial runtime to a language that compiles to native code.

iOS has had the benefit of superb hardware, but as Apple learned to their cost in their fight with Microsoft for the 80s desktop market, a platform lives and dies by the software that runs on it. The App Store made it easy for developers to sell software, but it was Objective-C/Cocoa that ensured these developers could write high quality software just as easily as they could sell it. Apple's choice to provide a great programming language, standard library and lets not forget one of the best IDEs around in Xcode, was a big part of iOS's success.

Sadly Objective-C is only available on Apple platforms. I am not a fanboi and I would love to work with Cocoa on Ubuntu or Android. GNUStep is good, but its frustratingly far from completion and Apple would be insane to release Cocoa on other platforms, and give them the leg up it gave iOS. If Mark Shuttleworth wishes his Ubuntu to become the next OS X, he would be wise to take a leaf out of the late Steve Jobs's book and ensure that his system is as beautiful on the inside as it is becoming on the outside.

EDIT. In the first paragraph of the original version of this post, I erroneously stated that Objective-C was designed at NextStep.

Posted on 14 Apr 2012

Creative Commons License
Slide to code blog is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at http://slidetocode.com/blog/.