|
08-04-08 / 00:08 : Objective-C / Java / Groovy (cjed) | Here a some major advantages of Objective-C (language used to build Cocoa and WebObjects) over Java :
Java does not comply with the message concept, as it directly binds the message concept to a method call on an object (that must be known). However the message (command) should be dissociated with the method call (result of the command sent).
The Objective-C runtime natively includes a messaging/delegation system (Responder Chain, delegates objects chain), and the target of a message (that can respond to it) isn't known (and hasn't to be) by advance. Cocoa frameworks (AppKit, etc.) use delegate objects definition (bind through InterfaceBuilder for example) in order to redefine/extend objects behaviours without the need to subclassing. With Java nothing has been planned to deal with that. The target object must be known (or at least its interface, even with reflection APIs, except when the class name is specified in a configuration file and in the client code - as with the O/R mapping layers) by advance. Set up a messaging bus (as the Responder Chain) would lead to a less than elegant syntax.
The Objective-C selector feature is more elegant than Java reflection APIs, and we can instantely (and easily) check if an object can respond to a message (without having to know its type). Classes also can be extended at runtime (or be swapped/replaced), and a native proxy aspect is present.
br> And what about Groovy : it brings nothing new compared with Objective-C, and despite its compatibility with Java JVMs, it requires an aditionnal compilation step (that hits the programming flow).
| | Comments | Write a comment | |
|