discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: speed of Obj-C vs. C++(slightly OT)


From: Philippe C . D . Robert
Subject: Re: speed of Obj-C vs. C++(slightly OT)
Date: Wed, 23 Apr 2003 22:10:43 +0200

On Tuesday, April 22, 2003, at 11:12 AM, Graham Lee wrote:
Jim McLoughlin wrote:
On Tuesday, April 22, 2003, at 01:36 AM, Dirk Theisen wrote:
You can always include C libraries for maximum speed.
AFAIK, some computational finance libs are in plain C anyway so you can get by with using C for the computations and ObjC for the rest (where message passing times do not matter).
Thanks for the response. I realized after posting that it all depends on how you split things up between C/C++ or C/Obj-C. I guess my question is that, assuming these ratios are equal, which is >> faster.
C++. The reason is that C++ is *not* an Object-Oriented language, it has structs and it has functions. When you have a method in C++ (such as myClass.doSomething(withThis);), the method is

This is a wrong statement (but please do not start a flame war here about what is OOP and what is not!). There is not just one definition of what OO is - by the way ObjC also has structs and also supports functions. C++ completely supports OO programming although it is not based on SmallTalk principles. Moreover OO by itself does not imply "being slow". And yes, C++ function calls are faster than ObjC method invocation, now how much this affects application performances is a completely different question, of course.

resolved at *compile time* into a standard ol' C function call, which probably takes all of around four cycles for a function that takes no arguments, and uses about the same number to leave if the function returns void.

This is not true either. Non-virtual functions are resolved at compile time while virtual functions are resolved at runtime using a virtual table!

-Phil
--
Philippe C.D. Robert
http://www.nice.ch/~phip





reply via email to

[Prev in Thread] Current Thread [Next in Thread]