Google's Programming Language, Go

I’ve done some searching (via Google, naturally, since “Go” is too short for vB search), and it looks like it’s never come up.

Has anybody here used Google’s Go language? Its intent is to be a garbage collected systems language to be used in place of C, Java, etc with a focus on making concurrency easier. Obviously it has a long way to go – for one while the library is growing, it doesn’t even have the meager support that Lua or Python have for various things. For instance, its (non-official) OpenGL package pretty much only works on a handful of Linux distros. Granted Go has a built in package “CGo” which will let you wrap C fairly easily, but still.

One thing about it that I think will make it a bit of a love it/hate it language is the fact that it intentionally lacks support for a number of things in the same family/paradigm as it (meaning a structured, procedural language) with no intention to add them. Things like method overloading, generic typing, default values, and so on were intentionally excluded to make you work within Go’s paradigm. In some ways it’s a bit pompous and annoying, but I can’t deny that it kind of works. It really is almost an authoritarian language in many ways, for instance, all programs are supposed to be formatted by gofmt, a formatter distributed with the compiler. Hell, the compiler doesn’t have warnings, only errors, and it’s an error if the curly brace is on the wrong line – or if there’s an unused import.

I have to say I kind of dig it though. I feel like Go’s inherent structure caters to the way I think about problems as a programmer, while imposing enough order to keep me from ruining things by trying to be too clever for my own good. It has a lot of allowances, like no need for forward declarations (okay, that’s not exactly a novel feature, but I’m tired right now and can’t think of a better example), but its order is clear and flows naturally from the specifications – i.e. if it calls you out on something it’s pretty predictable and easy to fix. No horrendous time-consuming bug hunts that things like circular inclusion errors can cause.

One thing I worry about is their concurrency support. On one hand, they’ve basically all but eliminated 90% of the things that make concurrency an absolute pain to set up and use. On the other hand, concurrency can be a huge pain to debug, regardless of memory access issues. It does worry me that if you use concurrency to the degree that they seem to encourage, that non-trivial systems could quickly (and even unintentionally if you’re working with multiple people) become a morass of a couple dozen pseudo-threads that do no real harm performance-wise, but because everything is being passed through channels and not easily traceable method calls, impossible to find exactly where things are going wrong. I guess this is a problem with event-based or component based environments already, but I can see it making things difficult to manage if you’re not very careful.

Then again, in the language tour the example of comparing two binary trees with channels was pretty damned clever.

First time I’ve ever heard of this language.

Does it have semi-colons?

Other than in for loops, no (though it does implicitly add semicolons when the compiler parses it).

I like the idea of forcing a specific syntactic style so that people don’t get caught up in holy wars over stupid shit like bracket placement, but I’m not really clear on what exactly the killer app for Go is. It showed up Lambda the Ultimate a few days back, so the discussion that develops there might be interesting to follow.

I don’t think there really is a killer app. Its 1.0 release was a little earlier this year, it really hasn’t been used extensively yet. Apparently Youtube’s backend is now in Go (according to the slideshow linked by Lambda), but I’m not sure that counts.

I do know that what was a three month project in C++ for me I did in a day and a half in Go – and it eliminated all the bugs the cpp version had to boot. Not to mention the code is conceptually cleaner, easier to follow, and probably runs quicker (I say probably because the conceptual package layout improvements made things more streamlined, but I can’t prove that I’m not taking other compiler-caused hits).

ETA: One odd thing about the language was they just decided that having a while/for distinction was silly and just made the two types:

for assignment; expression; assignment
for expression

Basically you spell “while” as “for” in Go.

Is it a functional language? I’ve tried teaching my beginning CompSci students functional programming using F# (because they also learn C#). Would go be an easier choice if we focus on the functional aspects? Is that how it will mostly be used?

It’s absolutely not functional – stored data and side effects out the wazzoo. Like I said, it’s a concurrency-focused garbage collected procedural language. It’s similar to a “cleaned up” C. Though some of its functions can get similar to Python at times.

If you want to teach a functional language I’d recommend Haskell. As long as you don’t touch Monads (and you shouldn’t because they basically are used to get around that pesky “functional” thing) it’s a pretty simple language to learn.

ETA: Though Go does have closures, and you could probably simulate currying with them. You might be able to simulate a functional language with it, but it’s not built for it.