What to do on Covid-19 lockdown? Let's start learning Go!

I had previously implemented a A n-body solution in Ruby . However, I was never really happy with the performance. Especially when running the inner solar system simulation, it would make the CPU on my laptop really pant.

So I decided to teach myself Go and re-implement the simulation. Go is an interesting language. I have messed around with other statically typed languages, but found them very hard to use. Go is much easier. One small aspect of the language that I found it hard to get used to was the fact that it has not adopted a lot of the functional paradigms that have been popular in Ruby, Javascript and other pure functional languages. But I am an old school OOP guy, and using structs as first class types seems natural. I also like that it is garbage collected and you can more or less treat pointers and objects the same from a syntax standpoint.

Other improvements over the Ruby version are the use of sprites to draw the planets (and maybe one of the reasons it is faster), trying to improve O(n^2) by using goroutines, elimination of some ui cruft.

Here is the code if you are interested: Golang N-Body Simulation