Computer Chess Club Archives


Search

Terms

Messages

Subject: Speed And Clarity Need Not Be Mutually Exclusive

Author: Graham Laight

Date: 01:33:34 01/02/03

Go up one level in this thread


On January 01, 2003 at 19:12:16, Bruce Moreland wrote:

>I assume that the compiler is going to get it right.  If I need to check up on
>the compiler later, I do.  But the point of a high level language is that you
>can write for clarity, and this should be what you do by default.
>
>bruce

In nearly all programming situations, speed is not a serious issue - and every
effort should be made to make the code clear and readable (this will be far more
useful and productive than fast code in the long run).

However - in programs like chess, a special situation arises.

* you have loops (or recursions) that repeat a large number of times

* the more of these loops you can do in the time available, the better your
chances of winning the game

Code outside of these loops is usually trivial in the time it consumes - but
code within the loops must run as quickly as possible.

Therefore, I would suggest that code within loops be written very much with
speed in mind. However - the clarity can be achieved by commenting this
particular code very heavily. Comments will have no effect on the compiled code.

-g



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.