GoLang – Initial Thoughts

A few people have recently mentioned Go to me. The last time I looked at Go I dismissed it as yet another language I didn’t have time to learn. I still feel a little bit like that but recently a few changes in my outlook have made me want to revisit:


  1. I have fallen out (well, had a bit of a spat) with Javascript. More specifically I have got frustrated with its asynchronous nature. I’m a great fan of simple things being, well, simple. Sometimes simple is just too hard in Javascript.
  2. I love working in dynamic languages but recognise that having a build phase in your CI pipeline that checks stuff is valuable. The sooner you can get feedback the better so the more your compiler can do the sooner you get feedback.
  3. I have realised that statically typed does not have to equal verbose (e.g. Haskell). Now that it not the only reason that I love dynamic languages. Being able to pass any old object into a function and then call a function on it gives sooo much flexibility (but with power comes responsibility) but I had an eye on Go’s interfaces and wanted to know more…

So, I decided to give Go a go…

My 20 minutes of dabbling reveals:

  • It is very clear with little syntactic clutter
  • Type inference makes it feel like a dynamic language
  • It is very familiar (C, C#, Java, etc)
  • It doesn’t have daft rules. For example, an unassigned int is 0 not undefined (see here for Javascript’s alternative)
  • Go has pointers (mmm, back to C anyone?), structs, pointers to structs, arrays (that you can append to). maps (hash tables),
  • Functions are first class and support closures
  • No classes but types can have methods…interesting
  • Methods can be added to types or pointers to types…argh, I thought I said Go was clear with little syntactic sugar :-/
  • But it has got interfaces :-) and whether a type implements the interface is dependent on whether it has the right methods…neat but I guess that could cut both ways…
  • Interesting approach to error handling – two return values one of which contains the error. If the error is nil then no error…
  • Some nice IO related stuff along with http support
  • Threads in the shape of goroutines with channels to support communication between threads – nice

In summary…interesting. Certainly worthy of further investigation, probably using a small app to spin something up and have a play with. Could fit well in the C#, Java space but also steal some of Node.js’ thunder…