discuss-gnustep
[Top][All Lists]
Advanced

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

Re: objective-c: how slow ?


From: Frederic Stark
Subject: Re: objective-c: how slow ?
Date: Fri, 31 Aug 2001 03:31:19 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.3) Gecko/20010801

Hi,

All this IMHO, of course.

Aurelien wrote:

Hi,

I was just wondering what was the impact of messaging on the speed of an objective-c program. I've read somewhere about the @SEL directive (I'm not sure about the name), which allows for optimizing often invoked methods. But is there a possibility that the compiler does such optimization right away ? Is the @SEL "trick" an absolute requisite when optimizing programs ?


You are probably referring to getting the IMP of a method. Not an absolute requisite at all, but handy to have for a very very very tiny number of specific cases. You get the perf of a C function pointer, and a lot of headaches when something goes wrong.


Does someone know about potential benchmarking results ? Has someone already tested the performance differences between programs written in C, Objective-C, C++ and Java ?


Given an infinite time to design and optimize, the performance is, from best to worse:

* C
* C++
* ObjC
* Java

(Java could be faster than ObjC with an exceptionally good interpreter, but, in my experience it does not happend. YMMV)

Now, nobody have and infinite time to design and optimize. ObjC enable a more powerful form of messaging, which simplifies a lot of problems, so more time can be spent on the design and high-level optimisation. Performance critical code can be (re)written in C++ or C, as ObjC interfaces exceptionnally well with C.

In many non-trivial projects, a lot of time is spent designing ways to work around the lack of dynamicity in the language, re-inventing a worse ObjC, with worse performance.

"Premature optimisation is the root of all evil". Choosing C or C++ for performance reasons when the problem is nicely handed by ObjC would be the ultimate premature optimisation possible.

Is there a reason (performance...) why an objective-c runtime and (at least) the foundation library shouldn't be ported to an embedded linux ?


I don't see any. I may be wrong, as I don't know much about embedded linux.

Cheers,

--fred






reply via email to

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