Alok Menghrajani

Previously: security engineer at Square, co-author of HackLang, put the 's' in https at Facebook. Maker of CTFs.


This blog does not use any tracking cookies and does not serve any ads. Enjoy your anonymity; I have no idea who you are, where you came from, and where you are headed to. Let's dream of an Internet from times past.


Home | Contact me | Github | RSS feed | Consulting services | Tools & games

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.