Go Performance

I’ve been learning Go over the past couple of weeks to get a broader view of languages, programming styles and idioms in general. Working purely in C++ can give you a slightly blinkered view. When you look at other languages you need to initially accept their way of doing things before you question it.

Hacker News, in particular, seems to mention Go a few times a week, and there is generally something interesting in each post.

One thing that comes up is Go performance, and interestingly, there is this post on Krzysztof Kowalczyk’s website.

The post refers to the alioth benchmark shootout web site with a comparison of Go to Java 7, finding that Java 7 is generally faster than Go in the benchmarks. What Krysztof’s post also describes is the uneven implementation of the benchmarks: the Java version (and presumably the C and C++ versions) are closer to the optimal implementation for those languages than the Go version is.

In short this benchmark site, whilst good for a quick look up of performance for mature languages with large developer communities, isn’t particularly good for new languages with smaller development communities. As with anything on the web these days, take it with a pinch of salt.

What is Go good for? As long as you don’t want a GUI (though you can use Qt bindings), any console or server side process can usefully be written in Go. Through correct use of go-routines, your process will scale with the number of CPUs/cores (concurrency is not parallelism). Not many other popular languages offer this out of the box, and certainly not with such ease and readability.

The general feeling I have from the last few weeks of searching, reading and watching Go articles and videos, is that Python and Ruby may (YMMV) be usefully retired in favour of Go, and for pure development speed with reduced development bugs, many C and C++ tasks may also be usefully replaced with Go (except where raw performance is a consideration). Go is a young language and performance is only going to get better.

Common wisdom in computer science is ‘use the best tool available’, and in terms of programming languages: ‘use a domain specific language’, yet many, many, developers still cling to one language to solve all problems when others are much more applicable. Even though Go doesn’t really have classic OO, or generics, I think Go is going to become an increasingly popular and useful language as it is currently one of the best tools available for getting improved performance on improving hardware without having to rewrite the code.

I just have to find a useful project to Go on: for the man with a hammer, everything looks like a nail!!