Go!
August 01, 2013The more I research languages for my personal enrichment, the more I like Go.
For one thing, their documentation is excellent. They explain not only how Go works, but also why. The FAQ is great to get your feet wet, but clearly the best document is Effective Go, which explains go's idioms in detail.
godoc
is likewise amazing/powerful as a documentation format. It is designed for searchability and understanding.
Vs. Javadoc, godoc wins. Here's Javadoc:
Calculates the logical conjunction of two matchers. Evaluation is shortcut, so that the second matcher is not called if the first matcher returns false.
To which class/method does this belong? That line doesn't make any sense in isolation. Contrast with this:
NewJson returns a pointer to a new
Json
object after unmarshalingbody
bytes
Not only does it tell you the function's name (NewJson) but what it returns (Json object) and how it does it (unmarshaling body
types).
Go is organized around making programmers happier and more productive. Eliminating bookkeeping is part of this goal:
- There are no header files
- Includes happen only once
- You don't have to apply interfaces to classes
- Types replace objects as the storage medium (they are in turn structs, mostly)
- 'Methods' are functions that apply to types, which can make them quite generic.
There are some things you might not like about go:
- Lack of functional idioms
- It's higher-level than asm/C, but it's lower-level than typeless languages
- Pointers (they are minimized, and you do know when to apply them)
- Declarations are 'backwards' to C users
- new/make dichotomy is weird, and a little hard to grasp.
There are idiomatic ways to deal with most of these nit-picks, so it's not a huge deal if you're uncomfortable at first. The idiomatic way in go is often the easiest.
Also, they have a formatting tool, gofmt, that ends most debates about where to put certain symbols in your code. Awesome.