Programming Languages

Chess programming lessons for beginners and intermediate

Moderator: Andres Valverde

Programming Languages

Postby Betsemes » 04 Apr 2012, 14:15

I'm just barely begun all this thing about chess engine programming. I now wonder whether the compiler I'm using is the right one. I was under the impression that C++ was the primary choice of languages to provide fast executable code as well as flexibility on what can be done. Now I'm wondering whether there is a better choice out there. So could someone post a guide of programming languages related to chess engine programming? Their pros and cons. I'm still not sure what I want my engine to be. I only know that I have loved chess since I was 15 years old and I was a fairly good programmer back in college. But I had not touched a compiler since December 1989, so I have much to learn.
Betsemes
 
Posts: 15
Joined: 22 Mar 2012, 18:54

Re: Programming Languages

Postby Ron Murawski » 05 Apr 2012, 06:00

Betsemes wrote:I'm just barely begun all this thing about chess engine programming. I now wonder whether the compiler I'm using is the right one. I was under the impression that C++ was the primary choice of languages to provide fast executable code as well as flexibility on what can be done. Now I'm wondering whether there is a better choice out there. So could someone post a guide of programming languages related to chess engine programming? Their pros and cons. I'm still not sure what I want my engine to be. I only know that I have loved chess since I was 15 years old and I was a fairly good programmer back in college. But I had not touched a compiler since December 1989, so I have much to learn.


What programming languages do you already know? It is always easier to create a project in a familiar language.

C will generate the fastest code but you need to dot every i and cross every t. There are plenty of IDEs and debuggers and other development tools.

C++ is a very complex language. It is very easy to write less efficient code in C++ using OOP features, but you can program in a subset of the language and circumvent that problem -- it's like writing C code, but using a C++ compiler to do it. There are plenty of IDEs and debuggers and other development tools for C++.

D is a very good alternative to C++. D is the language C++ should have been. On Linux and Mac it is 32/64-bit. The last time I looked at the language, the Windows version was 32-bit only. There's only a couple of IDEs that support D. I have not used D, so I can't comment on the quality of the IDEs or on the debugging.

Vala/Genie - For Vala you program in a C#-like language - it transpiles to C code and then compiles the C code for you. The generated C code is very clear and very efficient. There is also the Genie language which is a Python-like language and also transpiles to C. Both Vala and Genie use the exact same compiler. Debugging can be problematic due to using a C debugger and not having a 1-to-1 relationship with your source code. I developed (and debugged) my move generator in the Genie language using the Geany IDE. It worked but was not ideal. On Linux you can use Anjuta as your IDE.

There are other choices, but they start getting esoteric. Like the Shedskin Python transpiler, etc.
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA

Re: Programming Languages

Postby Betsemes » 05 Apr 2012, 14:12

Ron Murawski wrote:What programming languages do you already know? It is always easier to create a project in a familiar language.

I did most of my programming by using Borland's Turbo Pascal 4.0 and Turbo Pascal 5.0 compilers. I learnt Turbo C 2.0 by myself and did all my programming on it whenever I was given a choice, otherwise, I was required to program on Pascal.

I recently downloaded Microsoft Visual C++ and I have trying to download Windows SDK for the 64bits compilers, but the installer hangs everytime and I'm considering deinstalling VC++ and download cygwin instead, but I'm still unsure. Does cygwin support 64bits?

C will generate the fastest code but you need to dot every i and cross every t. There are plenty of IDEs and debuggers and other development tools.

This almost convinces me to go for C. "Almost" means I'm still unsure. I'll ponder this for a short while.

C++ is a very complex language. It is very easy to write less efficient code in C++ using OOP features, but you can program in a subset of the language and circumvent that problem -- it's like writing C code, but using a C++ compiler to do it. There are plenty of IDEs and debuggers and other development tools for C++.

D is a very good alternative to C++. D is the language C++ should have been. On Linux and Mac it is 32/64-bit. The last time I looked at the language, the Windows version was 32-bit only. There's only a couple of IDEs that support D. I have not used D, so I can't comment on the quality of the IDEs or on the debugging.

May I correctly assume we may write less efficient code too with D?

Vala/Genie - For Vala you program in a C#-like language - it transpiles to C code and then compiles the C code for you. The generated C code is very clear and very efficient. There is also the Genie language which is a Python-like language and also transpiles to C. Both Vala and Genie use the exact same compiler. Debugging can be problematic due to using a C debugger and not having a 1-to-1 relationship with your source code. I developed (and debugged) my move generator in the Genie language using the Geany IDE. It worked but was not ideal. On Linux you can use Anjuta as your IDE.

There are other choices, but they start getting esoteric. Like the Shedskin Python transpiler, etc.

Thank you Ron.
Efrain Caro
Betsemes
 
Posts: 15
Joined: 22 Mar 2012, 18:54

Re: Programming Languages

Postby Ron Murawski » 06 Apr 2012, 08:29

If you already know C, then it is probably your best language for chess. My favorite C compiler on Windows is TDM:
http://tdm-gcc.tdragon.net/
It's a 32/64-bit version of MinGW (GCC ported to Windows) with libraries and toolchain. It builds free-standing exes that, unlike some other MinGW compilers, does not require external dlls.

Now you need to choose an IDE!

Take a look at my chess programmer's page
http://www.horizonchess.com/pmwiki.php? ... rogramming
You can find lots of compilers, editors, IDEs, and programming/chess tools. I need to add another two more IDEs there:
http://qt.nokia.com/products/developer-tools Qt Creator
http://sourceforge.net/projects/orwelldevcpp/ Orwell Dev-C++

Betsemes wrote:May I correctly assume we may write less efficient code too with D?

Yes. But if you know the D language well, then the efficiency loss is not so bad. You will need to give up some of the language features in order to achieve good efficiency so, just like with C++, you would need to use a C-like subset of the language.
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA

Re: Programming Languages

Postby Betsemes » 06 Apr 2012, 12:38

Wow, thanks!! Lots of cool stuff.

Thank you very much.
Efrain Caro
Betsemes
 
Posts: 15
Joined: 22 Mar 2012, 18:54


Return to Chess Programming Lessons

Who is online

Users browsing this forum: No registered users and 1 guest