Why Objective-C?

Although gcc compiles ObjC as well as C and C++, you don't commonly see ObjC programs out there. As far as I know, AgentD is the first one developed under and released for Linux. What follows is not an indepth comparison between languages, but the reasons I came to use and like ObjC.

I'm a contract programmer and in 1992 I began working on a proprietary financial investment application in C under DOS. Nothing special there, and it was a set-up that worked well for a couple of years. Near the end of that time it was becoming clear that our application had evolved so much that it was cumbersome to make additional changes.

We did an OO redesign and evaluated the many OO languages available. For a number of reasons, we went with C++. At the same time, we dropped DOS in favor of Unix. With some irony, both Objective-C and NeXTSTEP were considered but rejected at this stage. Again, it was a solution that worked well for a couple of years. Then we abruptly hit the wall. It became necessary to do some "interesting" data manipulations and C++ wasn't making it easy. Rather than hacking out a solution, we went back to the drawing board.

When we started to redesign again, we went looking for the obvious faults in the old design. To our surprise, there were none. The design still fit our domain, even after two years of evolution (just one of the advantages of OOD). Our search for the real problem eventually landed us right on C++. C++ supports OO through user defined types, type encapsulation, and inheritance based polymorphism. This was no longer sufficient for our new extensions, we needed something that behaved more like an actual object (interface polymorphism).

We went back and looked at the languages with object support and the front-runners were Objective-C, Smalltalk, and CLOS. We made the sensible choice to stay in the C family. In any case, the switch to Unix was serendipitous because it opened up all those solutions to us. I have no doubt we'll hit the ObjC wall after a few years and it's nice to know we have no glass ceiling. Cheers to the FSF and all the developers who copyleft their code.

So we recoded our app in ObjC. We expected more of our code to carry over from C++, but that was not the case. ObjC more cleanly implemented our design and it was easier to create many things from scratch than it was to hack up our old code. In the end, our ObjC version turned out to be smaller and faster than the C++ version. I am told that this is atypical. :)

Cheers to NeXT for OpenStep and to the many coders involved in GnuStep. Although I have never programmed under NeXTSTEP, ObjC or otherwise, I am pleased to see work being done to release the OpenStep standard in a freely available implementation. I had started working on AgentD before using libobjects (aka, GnuStep Base), but I have already migrated my classes to inherit from NSObject and eventually will work them more properly into the hierarchy.