Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: OOP: objects and methods

Author: Bo Persson

Date: 02:35:48 09/23/03

Go up one level in this thread


On September 22, 2003 at 18:09:24, Daniel Clausen wrote:

>On September 22, 2003 at 18:01:06, Bo Persson wrote:
>
>[snip]
>
>>Yes, but I just use objects because it improves my program.
>
>Did you start directly in C++ or did you switch to C++ later? In case of the
>latter, do you have any idea what speed penalty (if any) your engine suffered
>from  the switch?

I have used C++ since it became available. I used C before that, and cannot see
any kind of "penalty" for changing language. I rather see an "abstraction
profit" from C++, in that it makes be think differently about what happens in
the program.

When I see a function like

bool piece::is_king() const
{ return MyIndex == King; }

I sometimes start to wonder where and why this function is used. I find it much
easier to locate these uses, than to find comparisons or smart macros in C.

I also know that I can easily change the representation of my piece class, if I
find something smarter, because all accesses to the internals are local to the
piece.h file.

Over time this helps me improve the engine, so that it runs faster and better.
In this way I think C++ can really be faster and better than C.


Bo Persson



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.