Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Move generation question for the big boys

Author: Vincent Diepeveen

Date: 13:12:13 09/16/01

Go up one level in this thread


On September 16, 2001 at 07:40:24, Bo Persson wrote:

>On September 15, 2001 at 17:52:29, Sune Fischer wrote:
>
>[...]
>
>>LOL, thank you all for your insight, I will try rewriting it to use pointers.
>
>Please, don't!
>
>>I've been using references ever since I read the following in a C++ book:
>>"Specifying a parameter to a function as a reference changes the method of
>>passing data for that parameter. The method used is not pass-by-value where an
>>argument is copied before being passed, but pass-by-reference where the
>>parameter acts as an alias for the argument passed. This eliminates any copying
>>and allows the function to access the caller argument directly. It also means
>>that the de-referencing, which is required when passing and using a pointer
>> to a value, is also unnecessary."
>>
>>That lead me to believe that pointers where actually slower, however I have
>>never tested for myself.
>
>A reference parameter is usually (close to always!) implemented as a pointer
>anyway, so you will not save anything but only mess up your code.
>
>
>
>>I have always believed that C++ was slower than C, some people I know thinks
>>otherwise. Anyone have an estimate of how much slower it is?
>>I've been thinking of rewriting to C++, but no way if it would slow it down!
>
>In the next post Vincent claims that *his* C++ code is much slower than his C
>code. This is not and indication that the C++ *language* is bad, just that it is
>possible to write very bad C++ *code*. You don't have to do that!
>
>
>For example:
>You can structure your code in C++ classes without any need whatsoever to
>allocate them dynamically.

In that case it's no longer c++ code but comletely imperative code and
can be as easily seen as C code.

If you write good c++ object oriented code then that's hell slower than
any C code of course written by the same programmer.

>C++ allows you to inline a large number of small functions, saving a lot of code
>without using *ugly* macros.

those can get inlined in C easily, in fact compilers are pretty good in
inlining such things. I get even the impression they inline too much
sometimes.

>The stronger typing of C++ allows a compiler to rule out some of the aliasing
>for parameters, because it can assume that a class Piece& and a class Square&
>are not aliased (even though they are possibly ints internally).

>>-S.
>
>Bo Persson
>bop2@telia.com



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.