On 18/01/2009, at 1:51 PM, Erik Buck wrote:

Both Objective-C message sending and C++ virtual function calls commonly prevent in-lining because the _compiler_ can not determine which code will actually be called. If you use Objective-C message sending or C++ virtual member functions, you forego most low level optimizations at the call sites.

Nicely stated. Presumably, one is using a dynamic method because you are having to defer to runtime exactly what code will be executed. If you did not have dynamic method dispatch, you would have to explicitly write the decision mechanism in the code yourself (conditionals or case statements). That is, the complexity does not go away – it may be that the complexity of the method dispatch has to be explicitly coded. A recent article on computer architecture states this "complexity preservation principle" rather clearly:

http://www.embedded.com/columns/technicalinsights/29111964?_requestid=1581

Now in Objective-C, the compiler (or linker) can't do static analysis to remove unnecessary method dispatches because your system is effectively open (dynamic) to have various add ins (categories, etc) that can happen at runtime. If a system is closed (as with Eiffel), a compiler can be much more ruthless in its optimization attempts, but of course you lose the ability to dynamically add functionality. With C ++, the complexity is to a very large extent left inelegantly up to the coder. Many programmers seem to feel safer that way.

Ian_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to