Author: Tord Romstad
Date: 09:01:29 08/10/04
Go up one level in this thread
On August 10, 2004 at 10:32:27, Anthony Cozzie wrote:
>I am thinking about switching Zappa from C to C++, primarily to make it simpler
>and easier to update. I don't think it would take that long (it could be done
>incrementally), and the code would be somewhat cleaner.
>
>Some of it is just a matter of taste: do you prefer
>
>int move;
>
>#define m_f_loc(A) ((A) & 0xFF)
>...
>
>or
>
>class move {
> private:
> int move;
>
> public:
> inline int m_f_loc(void) { return move & 0xFF; }
>}
>
>I am fairly sure these will generate the same assembly.
They probably would. I prefer the plain C version, though. Chess programs
are typically rather small and simple programs, written by a single person
rather than a big team. In other words, it they are precisely the kind
of programs where the advantages of OOP aren't really very important.
There are probably cases in a chess program where using classes would be
slightly more convenient or elegant, but I think the difference is not big
enough to matter much in practice. Sticking to ANSI C ensures that the
program is more easily portable to a wide range of platforms (C compilers
are still more widespread than C++ compilers, I think), which, at least
to me, is more important than the very minor advantages switching to C++
would buy me.
Tord
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.