public
Last active

Reasons why Go works for me

  • Download Gist
gistfile1.md
Markdown

Some notes on why Go works for me and why it might work for you if you're looking for another language to add to your repetoire. Goes without saying that this reflects my personal taste.

Go features that I particularly like

  • Multicore is the future so I like that Go has concurrency built right into the core. Goroutines and channels provide a very accessible metaphor for thinking about concurrent programming. They're supported by language features that really make Go shine in this area. The select statement, for example, makes it easy to listen to and synchronise events from different concurrent threads.
  • Provides both pointers and value types, but the pointers are safe and managed. Automatic memory management means its safe to return a pointer to a local variable.
  • Interfaces in Go are smooth and unobtrusive. They automatically apply to anything with the right function signature so you can define interfaces that are satisfied by 3rd party code without you having to change it.
  • Errors are signaled early and right where they occur so you're in a position to deal with them. This results in writing code that actually handles them properly and reduces the need for that nasty situation where you have a global exception handler that wraps the whole application just in case.
  • Garbage collection is a big positive, although I haven't used a non GC language seriously for a long time.
  • It's imperative, not functional, which fits the way I like to approach problems.

Most of all I find that Go makes me more efficient:

  • Code compilation speed: just seconds to compile to a binary. Makes for efficient coding cycle: write, build, test
  • Testing, benchmarking, profiling, code coverage, documentation are all built into the standard go tool.
  • Code is extremely readable for a C derivative. Removal of subtyping and aliasing means that there is no hunting through spaghetti to find why functions are being called. No semicolons.
  • Standard code formatting built into go tool means every piece of code I look at anywhere is instantly familiar.
  • Applications compile to a single binary making deployment very simple. Dependency management is done at compile time rather than deploy time.
  • Package imports are URL based so to find the source code you just copy it into your browser's address bar

I just joined a company with a large Go codebase so I speak from recent experience about how easy it is to find, read and understand Go code. You immediately feel the benefit when you have to work with a large team's code.

Some woolly stuff that I can't quantify:

  • I find the code I write in Go tends to be much more error free than in other languages
  • Standard library is high quality and pretty comprehensive.
  • The core Go developer team give me a lot of confidence in the quality of their code
  • There is very little cruft in the language - almost everything feels like it's there only because it has to be.
  • The language is small and can be easily learned in a few hours.

Obviously there are areas where I feel Go could do more but for the most part I don't miss the language features that weren't added. The big area people point to is lack of generics but aside from the simple use case of avoiding repetitive code, I don't miss them at all. Most problems that I thought I might need generics for have turned out to have different and better solutions.

Anyone looking for some good primers on Go should head here: http://dave.cheney.net/resources-for-new-go-programmers

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.