🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.oop.macapp3
1 messages
1 total messages Started by Alger, Jeff,VCA Mon, 28 Dec 1992 18:15
Re: Performance tests...
#47
Author: Alger, Jeff,VCA
Date: Mon, 28 Dec 1992 18:15
49 lines
2687 bytes
Richard,
 
Sigh.  I wish this old saw about OOP performance would just go away.  Here is
the truth:
 
1. OOP programs are considerably smaller than non-OOP programs (1/4 to 1/10,
depending on whose study you read).  In addition to direct performance
benefits (i.e., less swapping) this means it is easier to get your mind around
the entire program.  The result is usually better algorithms, which will always
swamp any language-derived factor.
 
2. OOP languages allow a compiler, carefully crafted and optimized, to handle
this sort of logic (please excuse me dropping into C rather than Pascal):
 
switch (aBlob->fType) {
case kTypeA: ...
case kTypeB: ...
...
}
 
Anyone ever look at the code produced by your average C or Pascal compiler for
this sort of conditional logic?  It isn't pretty and it also isn't fast.  Yet
this sort of branching is all over the place in procedural code.  A compiler
will almost always do better than a programmer in such circumstances.  Put
another way, in large part OOP compilers take on the task of writing code you
yourself would otherwise have to write but they do it FASTER and SMALLER, not
slower and bigger.
 
3. If you really want speed, use C++, not Pascal.  I'm not going to debate the
merits of the two languages here other than to note that Pascal's dispatching
scheme is more compact but slower.  One of the explicit design objectives of
C++ was to be as efficient as C unless you use polymorphism, and even then to
use the fastest dispatch scheme of all the major OOP approaches.  That is, you
can recast a C program as a C++ program with non-virtual methods and have
IDENTICAL performance characteristics but considerably better-structured code.
And if you use polymorphism, C++ will run at least as fast as anything else.
As an indication, the switch-case logic above would be dispatched with (I
think) two extra machine instructions per case compared to simple function
calls and many, many times faster than a real switch-case.
 
It is unfortunate that so many people in the MacApp community have been blinded
by MacApp's relative slowness and size (there are valid reasons for both, but
due to how much MacApp does) into thinking OOP generally is slow and big when
generally the opposite is true.
 
Regards,
Jeff Alger
SBM International
 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads