D versus Objective C Comparison
Michel Fortin
michel.fortin at michelf.com
Mon Feb 2 04:51:53 PST 2009
On 2009-02-02 01:39:40 -0500, John Reimer <terminal.node at gmail.com> said:
> "The Objective-C language defers as much as it can from compile time
> and link time to runtime. Whenever possible, it does things
> dynamically. This means that the language requires not just a
> compiler, but also a runtime system to execute the compiled code. The
> runtime system acts as a kind of operating system for the Objective-C
> language; it's what makes the language work."
>
> This is actually kind of interesting because it would seem to make
> Objective-C slightly comparable to the C# language in that it's more
> than just a language (as is Java). It's a platform (and the beauty of
> the platform is really only extensively demonstrated by the OS runtime
> functionality that supports it ... and Cocoa).
Yeah, but the Objective-C runtime is pretty microscopic compared to
Java or the C# runtime. There is no such thing as a virtual machine.
What the Objecitve-C runtime does is this, and only this:
1. It manages a list of registered classes, and their associated methods.
2. It provides a method dispatch mechanism, and manages a list of
registered selectors.
3. It provides various support routines for the compiler (exception
handling, synchronization).
For comparison, the D runtime does half of 1, and whole of 3, and a lot
more. If you start counting parts of the Foundation framework in the
runtime, then you'd have a base object class, an exception class, a
thread class... But technically, Foundation is not part of the runtime,
even if it's pretty necessary to do anything.
I'd say that the Objective-C runtime is smaller than druntime since it
does less (no TypeInfo, no array concat, no associative array, no
thread support, etc.), although I haven't measured anything. On the
other hand, the "standard library" (the Foundation framework) is
probably bigger than both Phobos and Tango together.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list