SW engineering, engineering management and the business of software

subscribe for more
stuff like this:

The Disposition of Objective-C

Some observations about Objective C, after over a decade of use.

Verbose

The most mundane of Objective C characteristics. A tautological extreme of syntax is required for basic usage. You get used to it of course. Objective C veterans rely heavily on the IDE and various other tools to assist. The exceptionally handsome and proficient employ a host of apparatus to overcome this particular demon, including snippets, keyboard macros, custom templates and whatnot. Your pinky will stretch like a wet sweater and your square bracket keys will wear out. In the end, the readability of the standard object message redeems and justifies many sins.

Ugly

Objective C is ugly. Take C. Wrap @directives in and around your class structures like a hobo wearing a trashbag. Send Smalltalk in a truck through the front window. Invent properties to clean up a bit. Finish up by flying in pigeons to drop ^blocks over the remains.

I love Objective C dearly. But I will never think of its syntax as clean or pretty.

Readable

Well written Objective C is remarkably readable. Some of this is due to its imperative tendencies. Mostly, the fault lies with its message passing syntax. Being able to intersperse meaning between arguments makes objc about four and a half steps closer towards self documenting.

Message passing syntax is the crown jewel of Objective C.

Compiled

Two big benefits here:

Between the compiler and static analysis, many, many errors can be caught by something not the programmer. The effect is an extra two pairs of eyeballs looking for very mundane and mechanical mistakes.

The second advantage is raw performance. It is the reason why every iDevice from the 3GS onward felt like the Snappiest device of its day.

Ecosystem

Objective C has one company in control of IDE, primary language implementation and the dominant libraries. Like a team with a good coach, Xcode (the IDE), LLVM (the compiler) and Cocoa (the library) are able to cover many of the deficiencies in the language. Furthermore, Objective C is a terrific language in which to write an SDK, framework or library, due to extensibility via language constructs like subclassing, categories, and also at a lower level via the Objective C runtime.

Static, Dynamic or Duck Typed

In practice, your ostentatiously humble author prefers static or duck typing, as overall bug count tends go down over the life of a project. For prototyping or places where you actually need to support a variety of types, id is a dynamic and handy tool. You want it to quack? Formal and informal protocols make it grow feathers.

Momentum

Objective C is aging more like wine than raw eggs. As it matures, we’ve reaped the rewards of properties, blocks, GCD and most recently ARC. No one but the truly inebriated would wager against further improvements. Ask yourself if your most frequently used language gets easier to use every other year.

What is Objective C really lacking?

A motto. I propose:

Objective C: The extensible, readable punctuation-based programming language.



in lieu of comments, you should follow me on twitter at twitter/amattn and on twitch.tv at twitch.tv/amattn. I'm happy to chat about content here anytime.


the fine print:
aboutarchivemastodontwittertwitchconsulting or speaking inquiries
© matt nunogawa 2010 - 2023 / all rights reserved