Re: Function calling
Re: Function calling
- Subject: Re: Function calling
- From: Ondra Cada <email@hidden>
- Date: Thu, 26 May 2005 03:39:07 +0200
Theodore,
On 26.5.2005, at 3:26, Theodore H. Smith wrote:
Of course strongly typed languages can be much faster.
Of course hand-tuned assembly language can be even much faster than
they.
Think about it.
Think about it: what's the point of using low-level tools unless we
truly need them?
MyClass* OtherClass::MyFunc() {
return &this->MyClassField;
}
void MyClass::Increment() {
this->Value++;
}
OtherClass Fred;
for (long i = 0; i < 10000000; i++) {
Fred.MyFunc->Increment();
}
A good C++ compiler will compile this with no functions called! It
will be all tight ASM code. Not that gcc is a good compiler,
though. I think MrCpp (from MPW) could handle these kind of cool
opts. But gcc I'm not so sure if it can do it on C.
As for Obj-C, these kind of opts are often impossible, because Obj-
C is weakly typed.
Thanks to good design.
Premature optimization is a bitch.
There is no point in these tricks: much better to design the complete
app using a flexible hi-level tool: dynamic ObjC objects are good,
bindings and CoreData and such things (which are of course based on
the dynamism) are better.
Then, if it is slow (which it most time is not), you can profile it
and re-write bottlenecks in plain C or perhaps even hand-tuned
assembly language.
The result is *much* better and *much* faster application, with
*much* less effort and time spent compared with the case of using
ugly non-flexible compile-time tricks like the "method" of yours or
like C++ templates and so forth.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden