(identity 'myron)

Thu, 10 Jun 2004

OOP: An evolutionary approach [/books]

I picked up this book by Brad Cox, the inventor of Objective-C, as a kind of reprieve from all the functional programming I've been doing lately. I figured it's also a nice way of finding out why he made the choices he did when he designed obj-c.

So far it's been quite enlightening. Written in the 80s well before the advent of Java, it argues for practicality more than anything through multi-paradigm programming and also "late binding". The latter is really interesting because he points out quite a few times that "dynamic binding is intrinsic to the very essence of a loosely coupled collection". And collections, as we know, is something Java got pretty wrong and is still in the middle of fixing with the addition of C++ style generics.

He also points out that even if a language doesn't have dynamic binding, then it's bound to be done manually by the programmer. What he probably didn't foresee was something like templates in C++ which essentially generates that kind of code for you....

Here's some good quotes I've pulled from the book so far:

Object-oriented programming can be added to nearly any conventional programming language by grafting a small number of new syntactic features alongside the existing capabilities of the language. [...] The hybrid retains both programming styles as tools to be picked up or laid aside according to the problem at hand.

The real value of an object-oriented language is not in the language, but in the libraries that become feasible once the language makes reusability possible.

Systems can be made malleable by retaining some elasticity into run-time. This involves relaxing the usual demand that everything be accomplished at compile-time. Dynamic binding, described later, is a move in this direction.

These technologies are tools, not panaceas. Each of them has their place, and none replace the others. I'd no more relinquish Smalltalk-style late binding for C-style early binding than I'd relinquish subroutines for pipes and filters. They are each different solutions for different jobs, and they all deserve their place on a programmer's workbench. They each have a specialized purpose for which they are the best tool for the job. Whether early binding or late binding is better or worse cannot be discussed in the abstract, but only in relation to how well it serves a specific task.

That last quote is my favourite. Yet more wisdom totally lost when Java came into vogue.

One thing I didn't expect from this book was Cox's mentions of Lisp. Not only was he versed in Lisp, he acknowledged it at the front of his book for "pioneering object-oriented programming" alongside Smalltalk-80 and Simula. It's this lineage that separates his language from C++ so much even though they're both C-based OO languages.

// posted at 23:23. permalink   comments

divider symbol