Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C or C++ for chess programming: speed

Author: Poschmann

Date: 23:06:33 10/20/99

Go up one level in this thread


There are different point of views:

1. At the level of a single source program line there is no difference between C
and C++. If You use a C- and a C++ compiler from the same customer (Borland,
Microsoft) both produce the same or nearly the same assembler output. You can
simply proof that: If You rename your source files from ".c" to ".cpp" for
example the Borland development suite uses the C++ compiler instead of the C
compiler. You can take a look at the assembler output or simply measure the
program speed (nps).

2. Distributing Your existing code to some C++ classes will result in a sligthly
slower program because of some overhead by C++.

3. C++ programs of larger projects (about 100000 code lines or more) are faster
then there C equivalents. It is due to the fact, that You can easier translate
Your problem into a good program design.
The performance in a chess engine is determined by a few algorithms of some
thousand program lines. The focus lies at the algorithms and the relationships
between them are very clear. You cannot improve them by C++.

4. If You write an user interface, selecting C++ is a good choice. Most of the
commonly used libraries (MFC from Microsoft, OWL or VCL from Borland) are C++
class libraries, which can easily used an modified.

If you have programmed in C since many years, You need possibly one or two years
to be a good C++ programmer. "Thinking" in C++ is completely different from the
same in C regardless many joint syntax.

Ralf





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.