Contributing Some Go to Rosetta Code

In any craft the best results are usually achieved by using the right tool for the job, so the Rosetta Code site is an invaluable resource for thoughtful programmers. There you can compare attempts at solving problems ('tasks') idiomatically in many different languages. I thought some of the gaps in the Go coverage should be addressed…

I started off with Smith Numbers - just by rewriting the existing C version in Go. It's interesting to compare the versions side-by-side; it seems clear that the Go version is less cluttered and therefore a little quicker to comprehend.

Next Calendar, a classic task I haven't considered since college days. I wrote that from scratch, populating a data structure first, then displaying it.

On to Combinations and Permutations where use of the standard math/big library made things very easy. Again, it's interesting to compare the readability of the code with some of the other languages implementing this task.

For the Archimedean Spiral. I decided to produce a (patent unencumbered) PNG file, and this turned out to be trivial using only the standard libraries. An interesting little diversion into libraries I might not otherwise have used.

Finally for now Julia Set and fun with fractals. Here I was able to introduce Goroutines in a very simple way, resulting in a speed-up of about 300%.

I would encourage everyone to have a go at contributing to Rosetta Code.

Comments

Popular posts from this blog

Terminal Emulation - Fun with a Go GUI

Writing Better Go: Code or Data?

Lessons Learnt: Porting an application from Go to Ada