Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Why is assembly more effecient than C?

Author: Robert Hyatt

Date: 15:18:25 09/27/98

Go up one level in this thread


On September 27, 1998 at 15:41:42, Danniel Corbit wrote:

>On September 27, 1998 at 14:36:22, Robert Hyatt wrote:
>[snip]
>>that's only true if you use the C++ syntactical tricks without using the
>>major C++ functionality, namely object constructors/destructor stuff, which
>>is where the overhead grows quickly.
>Actually, constructors/destructors are no more or less efficient than
>malloc/free+initialization calls, and you don't have to remember stuff.  There
>are real penalties in C++ though.  RTTI, exception handling and a few things of
>that nature can add overhead.  It's less than one percent though.  The algorithm
>chosen is so much more important than the language used that the language choice
>truly pales in comparison.  There are some tiny gains for assembly also.  For
>instance, you cannot do a rotate right with carry or rotate left with carry in a
>single cpu cycle in C or C++ like you can in assembly.  On the other hand,
>optimizing compilers can do some pretty clever stuff that assembly language
>programmers would be hard-put to find.
>
>Typically, 90% of the time spent in a program happens in 5 or 10% of the code.
>So if you optimize the hot spots, that is where the benefits are to be reaped.
>
>But I agree with Amir that little will be gained by rehashing the choice of
>programming language.  There are very successful assembly, C and C++ programs
>that I am aware of.  If one had a large advantage, they would all be written in
>that language.


not exactly.  IE I can't imagine that a C compiler + optimizer can beat
hand-tuned asm code, even if I write both the C and the asm code.  The
guys that write the optimizers are good, but they aren't as good as
someone that has been programming asm code for 30 years...

The main reason everyone doesn't use ASM code is portability, *not*
speed.



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.