Author: Landon Rabern
Date: 16:18:02 08/18/00
Go up one level in this thread
On August 16, 2000 at 20:23:50, Vincent Diepeveen wrote: >On August 16, 2000 at 19:41:46, Dann Corbit wrote: > >>On August 16, 2000 at 18:56:15, Tom Kerrigan wrote: >> >>>C++ is a superset of C. >> >>This is largely true, but there are enough exceptions to make a remark. >> >>There are a very large number of legal C programs which cannot be compiled as >>C++. There are C and C++ programs which will operate differently, depending >>upon whether you are compiling as C or C++. Trivial examples: > >Those examples are not real true. They form the difference between >an OOP language and an imperative language. Therefore the difference is >logical. The core of a chess program however compiles perfectly fine. > >In fact what i did to the auto232 player as patched by Remi Coulon, >i renamed a few 'cout' commands to printt, renamed the c++ file to c and >it worked at once. > >If you have an interface that's doing all kind of things like putting >multiple boards on the screen, then if you write a very neat way of C, >like nice modules, it's no problem to do this in C. If you write in C++ >then with less experience it's easy to make objects that show >multiple boards. > >Personally the only 2 big advantages of c++ which i miss a bit in C >are > - call by reference is real cool > - data-hiding if programs get bigger that really is cool, > especially the first few years i programmed in C i suffered from > this. > >What i dislike of C++ > - you need to write hell of a lot more code to do the same, > now hopefully that's because i'm bad in C++. > - a simplistic c++ program where you use a few of the c++ features > compiles to incredible sizes, and it's dead slow. For example i > planned to write the datastructure in the diep-win32 interface > in c++, so that the gamedatabase could use a nice OOP methods, > but after a bit of testing it appeared that using nice c++ it would > get incredible slow. > > Now i program it in C, and after some toying with a lot of typedefs > and structures i really like that way more now. > >Personally i don't see however why someone who starts to program now, >would NOT start with C++. As you learn > a) c++ very good > b) you learn tricks to prevent the above slowness of c++ to happen if > you need it. > >So personally i would advice to start with C++ directly. C is for dinosaurs >from the previous century, who were born before or short after 1970. I was born in 1981 and I started with and still use C. I know C++, but I think OOP is not necessary for a chess program, especially one with a single author. -Landon > >>/* Perfectly legal C, but not legal C++ */ >>/* Hint: just changing the variable names to non C++ keywords is not enough to >>fix this program to make it legal C++ */ >>#include <stdlib.h> >>int main(void) >>{ >> int *new = malloc(5); >> int delete = 0; >> return delete; >>} >> >>/* Legal in C and C++, but answers are different: */ >>#include <stdio.h> >>int main(void) >>{ >>printf("sizeof the letter 'a' is %d\n", sizeof('a')); >>return 0; >>} >> >>>You will be able to write your chess program in C, compile it with a C++ >>>compiler, and get exactly the same performance. >>> >>>If you use C++ features, your performance will decrease depending on which >>>features you use and how often you use them. The performance hit can range from >>>trivial to extreme. >>> >>>In my opinion, the goal of OOP is to organize and simplify complicated things. I >>>don't think a chess program is so complicated that it can benefit from OOP. >> >>I do agree with your general premise.
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.