[Adium-devl] LMX plans

Colin Barrett timber at lava.net
Fri Mar 2 11:37:43 UTC 2007


On Feb 28, 2007, at 10:06 PM, Evan Schoenberg wrote:

> That all sounds like a good thing to me, with the possible caveat  
> that I'm concerned about things being more difficult to work with  
> when written in straight C.

It's not that bad. LMX has really only been using objects as big fancy  
structs (not a whole lot of inheritance going on), and for something  
where you have a number of distinct data types, none of them closely  
related, and/or have a lot of composition going on, structs and C can  
work wonderfully, in my experience.

I've found that creating large systems in pure C starts to get painful  
when you want to modify the behavior of an existing data type in a  
subtle way (or not so subtle) without changing other things about it,  
*and* still keep the old data type around. In a normal object oriented  
system, you would just subclass. C, unfortunately, has no easy way to  
do this, and you end up with a lot of code duplication, or you have to  
go back and generalize your existing struct, and add a union to it to  
do composition. And then you have to change all the callers to use the  
new style. Ugh!

I don't know how closely you've looked at how GObject is implemented,  
but there are some crazy crazy things going on in there to fake  
inheritance. Perhaps using a supporting library, already rife with  
data types would be better (but not nearly as fun ;). Of course,  
that's Mac-arena's decision to make.

In short (IMO and IME):
C: Good for composition. Bad for inheritance. Good for speed,  
portability, and/or utility.
ObjC: Good for composition. Good for inheritance. Bad for speed,  
portability, and/or utility.

-Colin




More information about the devel mailing list