Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C or C++ for Chess Programming?

Author: Sven Reichard

Date: 23:03:01 08/17/00

Go up one level in this thread


To add my 1/4 byte:


On August 16, 2000 at 20:23:50, Vincent Diepeveen wrote:


>Personally the only 2 big advantages of c++ which i miss a bit in C
>are
>  - call by reference is real cool
>  - data-hiding  if programs get bigger that really is cool,
The best feature imho.
>    especially the first few years i programmed in C i suffered from
>    this.
I would add dtors, which can by (ab)used for all sorts of neat things.
And let's not forget templates.
>
>What i dislike of C++
>  - you need to write hell of a lot more code to do the same,
>    now hopefully that's because i'm bad in C++.
Not my experience.
>  - a simplistic c++ program where you use a few of the c++ features
>    compiles to incredible sizes, and it's dead slow. For example i
>    planned to write the datastructure in the diep-win32 interface
>    in c++, so that the gamedatabase could use a nice OOP methods,
>    but after a bit of testing it appeared that using nice c++ it would
>    get incredible slow.
Which features are those? As in every language, when writing a program you need
a general idea of what the compiler makes of it, in order to avoid overhead.
However, today's compilers are generally smart enough to, e.g., not emit
vtables unless they are absolutely necessary.

>Personally i don't see however why someone who starts to program now,
>would NOT start with C++. As you learn
>  a) c++ very good
>  b) you learn tricks to prevent the above slowness of c++ to happen if
>     you need it.
>
>So personally i would advice to start with C++ directly. C is for dinosaurs
>from the previous century, who were born before or short after 1970.

Go, Bjarne!!!
Sven, aka Pterosaurus germanicus (*1970)
(I'm writing a template library which is supposed to culminate in a decent
engine [Codename: Alice - any objections?]. After working on move generation for
a long time [I also have other hobbies and even kind of a life] I implemented
and tested AB and qsearch w/o SEE between Sunday and Wednesday. I think
developing C++ takes longer in the beginning, but gets faster in the end.)

>>
>>/* Legal in C and C++, but answers are different: */
>>#include <stdio.h>
>>int main(void)
>>{
>>printf("sizeof the letter 'a' is %d\n", sizeof('a'));
>>return 0;
>>}
This program's output is compiler and hardware dependent, but that has nothing
to do with C/C++, does it?


>>>In my opinion, the goal of OOP is to organize and simplify complicated things. I
>>>don't think a chess program is so complicated that it can benefit from OOP.
If not a chess program, what is?



This page took 0 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.