Alok Menghrajani

Security engineer at Square. Previously co-author of Hacklang and pushed for adoption of 100% https at Facebook.

Home | Contact me | Github | Twitter | Facebook

A short post about how writing a chess engine in Golang turned out to be a fun way to improve my knowledge of the language.

Over the years, I have had to write (and review) code in various programming languages: perl, java, php, javascript, C++, ocaml, python, etc. and most recently Go.

In general, programming languages are similar enough that I'm able to hack on existing codebases without having to formally learn the language. I gradually pick up language constructs and build an understanding of things by looking at existing pieces of code. In most cases, learning the language itself isn't the time consuming process, it's the frameworks, tooling, libraries, etc.

Recently, a short exposure to Go left me wanting to learn more. I decided to spend a few days writing a chess engine "just for fun".

After about 4 days and 900 lines of code, I had a working piece of code that can solve chess puzzles. My engine handles the obscure en-passant and castling rules (even though those aren't needed in most chess puzzles).

I'm unsure if the code I have written is "idomatic", I however have a much better understanding of Go. If you have a few days off, why don't you pick an unfamiliar programming language and try the same experiment?

Feel free to check out the source code.