D versus Objective C Comparison

Chris R Miller lordsauronthegreat at gmail.com
Sat Jan 31 17:51:57 PST 2009


Michel Fortin wrote:
> On 2009-01-31 18:50:52 -0500, Walter Bright <newshound1 at digitalmars.com> 
> said:
> 
>> Michel Fortin wrote:
>>> One area I think Objective-C to be very great and that you haven't 
>>> touched is for creating stable APIs. In Objective-C, contrary to D 
>>> and C++, you don't have to recompile every dependency when 
>>> reordering, adding and removing member functions in a class. In 
>>> 64-bit Objective-C 2.0, you can even add variables to a class without 
>>> care about recompiling derived classes. Compare that to D, where 
>>> exposing a class as a public API will either force you to not change 
>>> much that class, or force your users to recompile every time you make 
>>> such a change.
>>
>> If you use interfaces, you can add member fields without needing to 
>> recompile clients.
> 
> Yeah, indeed. I hadn't thought about that. That's a pretty interesting 
> thing about interfaces now that you make me think about it.
> 
> But exposing only interfaces makes the API harder to use. In Cocoa, 
> classes gain new methods at each new version of the framework (read each 
> version of Mac OS X) and it doesn't hinder programs compiled with 
> earlier versions of the framework.
> 
> If you had a smart enough dynamic linker and the signature of each 
> function in the virtual table, you could do that in D too by creating 
> virtual tables and updating offsets in the code accordingly while 
> linking. (Objective-C doesn't work like that, but it has the same 
> effect.) Alternativly, it could be done in some static initialisation 
> phase.

An increasingly interesting toy to study (I would think) would be 
Categories - the ability to take an existing class and just randomly 
tack on additional receivers.  Perhaps this is exclusive to 
Objective-C's message-receiver architecture, but it's a curious little 
technology nonetheless.



More information about the Digitalmars-d mailing list