Thursday, November 12, 2009

Why I'm not very excited about Go

When I first heard Rob Pike and Ken Thompson had created a new programming language my first instinct is, "I'm sure it'll be cool, these are brilliant guys!" Unfortunately that is not the case, mostly because I think they made some bad design choices, and because the "cool new things" aren't actually that new, or cool.

The first major mistake was using a C derived syntax: braces and semicolons. I know some people don't like significant whitespace, but if you aren't properly indenting your code it's already beyond the point of hopelessness. The parser ought to use the existing structure instead of adding more punctuation. Readability is one of the most important attributes of code, and this syntax detracts from that.

The next mistake is having a separate declaration and assignment operator. I understand that the point of this operator is to reduce the repetition of typing out the types name both in declaring the variable and in initializing the value. Yet it seems the purpose of the := operator is to avoid typos in variable names that are possible by making all assignment an implicit declaration if the variable wasn't already declared. I can see myself making many more typos by forgetting to use the := operator, and in cases where I make a typo in a variable name it would inevitably be caught by the compiler when I attempted to actually use it (the fact that this is an attempted declaration means the variable won't have been declared elsewhere).

The final mistake was not providing generics. C++'s templates is one of the things that make the language head and shoulders more useful for me than C for tasks I need to preform; generics allow one to provide reusable data structures. While Go seems to have something akin to generics with their map data structure, it disappointingly doesn't appear to be exposed in any way to user code. One of the things I've found makes me most productive in Python is that any time I need to perform a task I simply pick the data structure that does what I want and it is efficiently implemented. Without generics, I don't see a way for a statically typed language to offer this same breadth of data structures without each of them being a special case.

In terms of features which I believe are overhyped the most important one is the "goroutine". As best I can tell these are an implementation of fibers. Constructs like concurrency should not be granted their own syntax, especially when they can be cleanly implemented using the other constructs of a language, look at the C library libtask as an example.

Further, the handling of interfaces, though interesting, appears to be an implementation of C++0x's proposed concepts (which won't be in the final standard). I view this feature as something that is most useful in the context of generics, which Go doesn't have. The reason for this is to be able to make compile time assertions about the types that are being templated over. Doing anything else is more clearly implemented as abstract inheritance.

I'm not writing off Go permanently, but I'm not enthused about it, someone will probably have to let me know when I need to look again as I won't be following along. Enjoy your internet travels.


  1. The := and the partially required ; remind me of Pascal.

  2. I think it's safe to say the Go authors are aware of libtask as its author, Russ Cox, is also one of the Go implementors.

  3. Separate stament like := is needed for proper variable scoping. Python historically has problem with that (which is sure to bite you, when using a lot of closures).

  4. The vast majority of things Google comes up with are kind of half ass and not very good. They've got search and GMail and that's about it. Their Ads system is good only because it's tied to search, they bought analytics, their code management system sucks, their cloud services suck royal goat balls, do I have to mention froogle, base, checkout, and all the others? This is Google's 1/2 ass attempt to get the community to fix up something they kind of use internally while looking good. It's junk.

  5. GO Interfaces are nothing like C++0x Concepts and you idea about is what Concepts are is a bit wrong too. Concepts are like type-classes in Haskell and generic constraints in .NET. The point of C++0x Concepts was to provide bounded quantification of parametric polymorphism, limits the set of types to only a sub-set you can pass as type parameter. "Compile-time" assertions is another C++0x feature static_assert.

  6. Python fan hating on C. Totally irrational and without much knowledge of history. := is not what you think it is, nor is mandatory whitespace.

  7. I'm with you on the generics, but I think Go set out to solve a different problem. Those remarks about significant whitespace and assignment/comparison operators are completely wrong. They are what Python got wrong and there it is not a coincidence that all other languages did it differently, and there's plenty of writing why this is true on the web.

  8. I have heard about that Google is processing one programming language which is mixer of C language and Python Language. It is little bit difficult to both kinds of programmer to understand the language. It is not universally accepted language.

  9. You really missed it with this post.

  10. Yeah. I think this post is way off. I've played with it and I think it's kinda badass.

  11. You're just showing your ignorance here. Stop blogging and go learn more.

  12. Couldn't agree more.
    1. Concurrency and parallelism have been distinct in funcitonal languages (haskell and erlang for example) for a while now (20 years?). Goroutines are nothing new.
    2. Channels are by-the-book ML style.
    3. The type system is not object oriented anymore. It's a dumbed down version of Haskell's type system (may not be a bad thing to simplify it). One thing Haskell does very well though is what you mentioned Go doesn't have: type variables and parameterised types.

    All they did was take Haskell types, ML concurrency, and a GC, slap shitty C syntax on it and call it a system langauge. Since there was nothing new done PL wise, I only see Go as an attempt to rebrand functional ideas so C people wont be scared to try something new.

    I'm sorry to say but a language with a garbage collector, fibers, a scheduler, channels, and no pointer arithmatic is not a system language. They are just selling it as one.


Note: Only a member of this blog may post a comment.