Computer Chess Club Archives


Search

Terms

Messages

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

Author: Dann Corbit

Date: 11:12:49 08/17/00

Go up one level in this thread


On August 17, 2000 at 04:10:10, Dave Gomboc wrote:
[snip]
>- Using templates where useful will lead to speedup vs. a C implementation of
>the same.

I am a *BIG* fan of templates.  Not only do they make for faster code, I think
the abstraction that they give to ADT's make them the best possible solution for
any ADT sort of problem.  I use them for data structures such as Skiplists and
Red-Black trees and for Sorting, and for anything else that is a generic
collection problem.

The code ends up much more readable as a template, since you can make it look
like everything is some simple atomic type.

E.g.:

   if (a < b) do_stuff();

looks better than:

   if (compare(a,b) < 0) do_stuff();

In my opinion.  Especially when you have a great big pile of complicated stuff,
the simplification you can achieve is very valuable.

The speed difference between C and C++ is miniscule and almost always overblown
by C advocates.  If you code using C++ as "a better C" the speed difference is
negligible.

On the other hand, if you are really new to C++, you won't be able to write
faster or better code than in C, if you know that language better.  It takes
several years to get used to the C++ mode of thinking.



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.