Postcards from a language tourist

Jumping once again on the “everyone else has blogged it to death, but meh!” category, I've spent a few days messing about with the google go (golang) programming language and thought i should jot down some thoughts here about it.

Its certainly interesting, that's for sure...

I'm a sysadmin by trade, and in no way consider myself to be a ninja rock-star programmer but from time to time i write code as part of my job, and occasionally I've even been known to write code just for fun in my spare time also.

However at one time or another I've written a few thousand lines of code or more in most of the languages many programmers have (VB, Java, C, C++, Perl, Ruby, Python, Bash) so dammit, I'm blogging my thoughts on golang !

In short, its good! But this depends on who you are and what you want out of it. I'm seeing it make a stir in the sysadmin blogs and circles, and i'm not really certain i agree with the sentiment that it's well suited there.

Here's what i like about golang:

  • Concurrency is definitely nice and well implemented, and heaps better than doing it in C or C++.
  • Channels are really, nice. Period.
  • The go fmt, go build, go doc etc tools are awesome.
  • The ability to compile quickly, and down to one monolithic binary is great for deployment.
  • The defer keyword is neat, and i like it a lot.

Right, so i'm gushing all the same things as everyone else... What didn't i like ? (for me, and in no particular order)

  • Lack of proper object orientation. Structs + methods is not the same thing as proper object orientation... Constructors and destructors weren't invented by mistake, you know ? (and yes, i know you can kludge a constructor, but its really dirty)
  • Refusing to build with unused variables and imports sucks for the development time work-flow. Yes, you can do _=package.method, but you're introducing code artifacts to avoid code artifacts, which is kinda dumb. A compile time flag to lower these to warnings would be great.
  • Its 'super fast', in the same way as C is 'super fast'... You stand back proud of your efforts and its execution speed, only to realize your code does very little that's actually useful. This is definitely less pronounced than with C, but its still a thing, in my opinion.
  • The total lack of proper exception handling. By 'proper' i mean not littering your code with 'if err != nil {}'. Checking for errors on every damn function call is just rubbish. It would be a nice option to have this as well as proper exception throwing, but without this choice its really very limiting. I know they did this to be thread safe and all, but it's horrid in this day and age to see it in a language.

So what do i think ? I think if you're a C coder you need to check out golang ! It could well be right up you're street. It adds a lot of nice concepts to a familiar feeling syntax, and you will likely love the compile times.

If you're a sysadmin... ehh; maybe, but maybe not. Sure, if you do low level CPU bound code as part of your job then it's going to be really nice for you, but if you're doing system scripts and such then i don't think its worth it over either ruby or python or maybe even bash if you factor in speed to hack together a working prototype. In my opinion Ruby is still the best language for small to medium web apps (together with Java, for the larger apps) and perhaps text manipulation heavy scripting, and Python is still the best all rounder for most other scripting tasks. Yes, golang is miles better on the deployment work-flow, but it just doesn't justify writing all your scripts in a glorified C.

That said, it's definitely been nice to see a new language get some buzz around it and I can see a lot of people taking up golang where their python scripts are too slow, or their C needs a lot of threading / concurrency (which is a lot of places, these days).