Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Any idea's on how long it takes to learn C++, then create a chessmonster

Author: David Rasmussen

Date: 00:07:36 12/11/01

Go up one level in this thread


On December 10, 2001 at 15:40:09, David Hanley wrote:

>
>Robert.
>
>Everyone had their chess program written in C/C++.
>
>I'd say use something else.  C/C++ is really a high-level assembler.  It

No it isn't. Especially not C++.

>sacrifices a lot of programmer time to make your code run faster.  But even
>running twice as fast won't make your prgoram a LOT stronger.  But it will make
>your programming take a LOT longer.
>

Not necesarily.

>If 1600 if your goal, you can do it in java, and a lot of your work will be a
>lot easier.  Java is plenty fast for a 1600 program on modern hardware.
>

Sure.

>Also:
>
>smalltalk
>lisp
>SML
>
>Are all things to look at!
>
>dave

Smalltalk, CommonLisp and SML are all nice languages in their own respect, but
there is no reason to choose any of those instead of C++. C on the other hand,
does have the negative features you outline.

Many people use C++ as either just a better C or on the other hand as an all out
object-oriented language. Either of these approaches can work well for a chess
program, performance-wise, if you really want them to. But for a first-time
project with emphasis on clarity and structure instead of optimization and
speed, neither of these approaches is good. And also, both styles is often bad
C++. A C-like approach will be too detailed and low-level for a such a project,
and on the other hand, an object-oriented approach will not be very natural to
many of the common chess program techniques and solutions. At least not without
a very thorough object-oriented design phase first. It is usually a bad idea to
force a certain style upon every phases of a project, especially when the style
doesn't fit the problem.

A good C++ programmer knowing tried and true C++ techniques and idioms will know
when to use what style and techniques and know that, if it is what the project
calls for, a C++ program can be expressed roughly as short and simple as with
any of the languages you mention above, but usually with much more flexibility
of style and performance.

A beginner (and many "experts") should read the book "Accelerated C++" by Koenig
and Moo, and start from there. Using the STL, one can achieve very short and
easy-to-maintain programs rivaling those of the languages you mention, but
already outperforming them in speed. Then later, if the need arises, the
performance-intensive parts can be rewritten. In other words, prototyping can as
easily be done in C++ as it can in, say, SML.

In fact, programmers of _all_ levels should start out this way when doing a
chess program: Use as large building blocks as possible (lists,vectors,hashmaps,
simple classes etc.) and program for an interface, _not_ an implementation, and
get a good basic design that does not focus on performance, but on clarity. One
can make a chess program using the STL and certain C++ techniques, which is very
short, and have a well defined structure. When this is done, if you have done a
good job of separating interface and implementation of your types and functions,
you can begin to elaborate on the performance intensive parts, or use more
efficient types etc.

The nice thing about this is that you will have learned C++ instead of SML,
which is always a good thing :), and also you will be geared for performance
from the beginning, without focusing on it. Also, C++ has a much larger
community and a broad support in tools and compilers, moreso than for any of the
other languages. And you will not have been forced to use only one style
(Object-Oriented or Functional) that may not fit the problem at hand.

/David



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.