Go for Competitive Programming Competitive ProgrammingSeptember 10, 2017
I first started writing Go during my time at UserTalk and have been using it occasionaly since then because of its minimal syntax and standard library that makes it a great language for writing almost any kind of software.
Whenever I’m solving a competitive programming problem, I usually use C or C++ (whichever works best) to write the solution mainly because they are both supported by almost all online judges and programming contests.
Moreover, I was recently solving a problem on HackerRank and decided to write the solution in C. The problem was quite easy but my solution always resulted in a Segmentation Fault. Here’s a link to the problem if you’re asking. Luckily, I found out that I could submit the solution in Go, besides other languages. So after +30 failed submissions (and out of frustration), I decided to translate the C code to Go and boom, it passed all the test cases flawlessly. Go being garbage collected here, unlike C, makes it really easy to focus on the solution and leave the task of memory management to the compiler. Also, by having a strong standard library, the number of lines in the Go solution is about half the number of lines in the C code. Here’s a screenshot comparing the two:
Go is minimal, concise, has a huge standard library, performs fast, backed by a company like Google, has a growing community, and many online judges already support it on their platforms and even though writing Go might require some mind shift, a programmer can easily adjust themselves to that. These all the reasons why I think it’s time for the ACM organization to consider Go as an official language in the coming ICPC contests.