As part of my continuing self-education and in following the advice of the Pragmatic Programmers to learn at least one new programming language per year, I've been messing around with Go in the evenings for the past few weeks. I've been working through the tour and trying out various exercises suggested there.
I'm a little ambivalent about Go as of now. The language has some really cool features that I like such as multiple return values and goroutines but I find the general structure of Go programs a big departure from what I'm used to in
Java. Frankly, I find a Go program's structure a bit disconcerting.
I learned Python a couple of years ago and Go programs seem to have an even less cohesive structure than Python. In Python, you put methods under a class heading but you still have to specify
self as the first parameter to the functions/methods
def'd under it. In Go, the
func definitions just have to be in the same package as the data structure(s) that they use and operate on—at least that's my impression for now, which of course may still be wrong at this point. You still have to explicitly "bind" a
func to an associated data structure by declaring the data
struct as a "receiver" in the
func header. Then you still have to explicitly use the receiver's reference inside the
func. In Go, there doesn't seem to be a notion of "
this" or "
self" as there is in Java and Python, respectively. There also isn't an implicit association between a set of data/fields with the
funcs/methods that operate on them that's based on the program structure. My impression when I read a Go program is that you just have a bunch of loose
struct and
func definitions and you have to manually/explicitly tie these things together.
I'll explain what I mean with an example in the next post below.