Chess Bin

Computer Chess Information and Resources

Choice of Programming Language

For my implementation of the Chess Game I selected C# mainly because it is a computer language that:

  1. I know best and work with every day.
  2. I would like to improve my skills in.
  3. Should be around for a while giving the project a longer life. 

There are however negative aspects to my choice.  C# cannot compete with C or assembly language in terms of performance.   This will means that a chess engine created in C# will probably be slightly slower in move searches compared to the same chess engine created in a programming language that compiles into machine code.


I have read sites that claim that the .NET framework is just as efficient and quick as unmanaged C++.  However I am skeptical at best.  I have seen a managed C# program choke on things that C++ would breeze through.  Maybe some of this has to do with implementation or optimization.  However I am a firm believer that optimized C++ unmanaged executable will usually be faster then optimized C# managed executable. 

As proof I would like to submit the fact that it has been years since the introduction of C# and yet the Windows OS is still entirely written in unmanaged code… even notepad.


However I stated before my goal is not to make the best Chess Engine that ever existed, just a fairly good one.  I believe the C# programming language will serve that purpose.


Comments (2) -

  • Jeremy Wiebe

    5/25/2009 9:15:35 AM |

    Interesting site.  The debate of performance between C# and C++ has probably been beaten to death, but reading your post here I was reminded of it.  I did some reading and I think it's partly a "holy war" on both side where each side can make their point if they tilt the test in their favour.  Smile  (On one site the C++ developer was rewriting the C++ test as close as possible in C#, which wasn't the way that a C# dev would write the test, and his C++ test was faster... go figure).

    Anyways, I thought this ( series illustrated the nuances of the performance debate nicely.  I'm sure there are places where C++ is still relevant, but I am convinced that in more and more cases a managed solution will be just as fast or faster for a given amount of effort.

  • aberent

    6/22/2009 8:08:20 AM |

    Thanks for the link.  I guess I can add that one day if I want to make a competitive chess engine that will play in tournaments I will probably to a port to C++.  Meanwhile I am so glad I selected C#.  It is so much easier to debug and code in a strongly typed language.  I already spend so much time chasing down bugs in my C# chess engine; I can’t imagine also having to deal with pointers and memory problems.  My advice is work out all the bugs in C#, port to C++ later.

Comments are closed