▄▄██▀▄███▄ ▄■▄▀▀▀█
      ███▀▄███████████▀▄▀               ███▄
      ▀██▄▀██████▀▄▀▀▀▄▀        ▄▄▀▄███▄■▀ █▀▀█
      ▄▄██▀▀████▄▄          ▄█▀▄▀█▄███▀▀▀▄▄█ 
    ▄███▀▄▀▄███▀▀█▀▀        ▄██▄█ ██████████▀ 
  ▄███▀▄▀▄▀▀▀█▀▄▀           ██ ██▒████▀▀▀▀▀▀▄▀
 ▄███ █▀▄ ▀▀█    ▄▄▄▄▄    ███▀█▀▀███▄ ▀▀             ▄  ▄  ▄▄▄  ▄▄  ▄   ▄ ▄   ▄
▒███ █▄█▀▀   █▄▀█▀▀▀▀▀█▄ ▀██▄▀▄▀▀███▄▄▀▄           █▄▄█ █▄   █▄▄█ █▄ ▄█ ▀▄▄▄▀
████ ▄▀▄▀   ███ ▄▄▄■ ██   ▀██▄▀▀▄▀▀█▀▀▄▀▄         █  █ ▀▄▄▄ █  █  ▀▄▀    █
▒███  ▀▄▀▄ ▀ ▄▄▄▀ ▄▀▄▀ ▀▄▄████ ▀██▄▀█▄▄█▄▄█▄
 ███▄ ▀▄ ▀      ▄▀▄▀▄▀▄█▀▀▀▀██   ███▀██▄▀█▄█▄      ▄▄▄ ▄  ▄ ▄▄▄  ▄  ▄  ▄▄▄ ▄▄▄▄▄ ▄▄▄  ▄▄▄  ▄▄▄  ▄▄▄
  ▀██▄ ▀▄  ▀      ▀ ▀  ▄▀██ ▄▄█▄██  █▀  ▀▄▀▄██        █  █▀▄█ █  █ █  █ ▀▄▄    █   █▄▄▀  █  █▄   ▀▄▄
    ▀██▄ ▀▄         ▄ ▀▄▄▀█▄▀▄▀█  ▀▄▄ ▀ ▄▀▄▀▄▀ ██      ▄█▄ █  █ █▄▄▀ ▀▄▄▀ ▄▄▄▀   █   █  █ ▄█▄ ▀▄▄▄ ▄▄▄▀
      ▀▀█▄  ▀ ▄▄▄ ▀    ██▄▀▄▀▄▀▄▀▄       ▀    ▄▀
           ▀▀           ▀██▄▀▄  ▀ ■       ▀ ▄▀
                          ▀█▄ ▀▄          ▄▀
                             ▀ ▄▄▀  ▄▄▄ ▀
posted by esells on Aug 30, 2018


This week I am lucky enough to be attending GopherCon which is a great conference that is focused on topics that revolve around the Go programming language. As I was sitting in one of the talks on day one something hit me: I don’t really belong here. This had nothing to do with gender, age, hair color etc but more to do with the fact that I was listening to seasoned developers talking to other developers about hard developer problems. It wasn’t necessarily the content that triggered this thought, it was more the fact that I don’t write code everyday and when I do, it is typically for side projects or for stuff my job doesn’t pay me to do. I am not a developer, I am a nerd who likes to play developer a handful of times each month. So if I’m not a developer, why would I spend the few “coding” cycles I have to write code using Go? Why not Node.js? Why not Python? Why not ____? Well, let me tell you why…

Go is simple, and I mean that in the best possible way.

But wait, let’s back up a bit…

My entire career has been in technology. I’ve done helpdesk roles, sysadmin roles, architect roles etc. Shit, I mean at one point in my life I was a tester for Palm Pilots. Along the way I’ve always played around with code using languages that anyone over 35 probably has touched. Early on it was Perl and shitty shell scripts. Later on I graduated to PHP. I played around with Ruby and Python and of course, tried my hand at C (doesn’t everyone?). Most of those I used at a specific job but then ditched them once I moved on. Then came Java. Oh Java and your incredible mess of libraries and heavyweight IDEs. I actually really liked Java and ended up using it for the one program that a company I worked for ended up using long-term. As a sidenote, I feel bad for the person that inherited that mess. Anyways, the point of all of this is to show that I had played around with many languages so, even though I am not a dev, I have seen enough to know what works for me and what doesn’t.

I was just coming off of my Java kick and was not feeling super excited about the Java ecosystem. It felt like anytime I wanted to write an app I needed to import 25 libraries, which then needed to import 50 other libraries. Then I needed to dick around with XML files and all sorts of other annoying shit to finally get an app that was painful to package. Not being a real developer it might have just been that I was doing it wrong, I’m not sure, but while writing the Java code was fun, everything else sucked. Then, on one summers eve, I saw a post on Hacker News talking about Go. Being a nerd I decided to give it a go (ha!) and check it out. After about 30-40 minutes I was all in, this was what I had been looking for.

So Why Go?

Strap in, I’m about to go wall-of-text on you…

What was it about Go then? I have long subscribed to the KISS principle, so when I started playing around with Go I fell head over heels for it. I hear people call Go boring and sometimes a bit verbose, for me that was exactly what I liked about it. It was simple in the sense that things were much more readable to me. I’m not talking simple as in you can start being ten times more productive in Go because it’s really easy to learn or something, I mean simple in the sense that the code you write ends up being self-documenting, even for non-developers. Not being a dev it was awesome to be able to understand everything that was going on in the code. I’ll use error handling as an example. People bitch about the error handling but I love it. I can see, without any magic, what is happening and how it is being handled. To this day I still do the tried and true

    if err != nil {

because it is 100% obvious what is going on there. Sure it takes a bit more time to type out but that doesn’t bother me. The lack of magic in writing your code is balanced with some magic that someone like me wants such as memory handling. That is the kind of magic I would rather not know about so have at it Go!

This has been the biggest reason why I’ve stuck with Go. I don’t have to worry about models, objects, build tools (Maven, I’m looking at you) or any of that shit. Could I implement my code that way? Probably, but I want my code to be as easy to read as possible. I usually have 2-3 files(remember, I am not a dev) in a single, flat directory. I can see you freaking out right now, but this works well for my small projects. I am able to separate the code so that specific things share the same spot/file, but I don’t need to dig through three directory levels only to find 10 files, one of which contains what I actually need. Yes, I know an IDE can help with this but that is another topic and I’ll touch on it later.

What about libraries? Yeah, they exist (and can be super helpful) but 90% of the code I write never needs them. Writing a web app in Go compared to something like Java is about as opposite as you can get. Web frameworks? What? My web framework is the Go standard library + the awesome HTTP Router library from Julien Schmidt. I get just the right amount of control all while reducing some of the more tedious stuff. Oh, and that library is like ~1k lines of code so if I do need to figure out what it is doing, it is pretty easy to poke around and find what I need. Did I mention the Go standard library? That thing is amazing, and as a cherry on top, it is well documented. When I am writing code I typically have two things open: my editor and https://golang.org/pkg/. In fact, probably half of my code is more-or-less cut & paste from the documentation. Seriously.

Guess what else I like about Go… No need for a heavy ass IDE. I can write code in Vim all day long without any issues. There are helpful plugins like vim-go, but to be totally honest, you don’t really need them. I do use vim-go but only about 20% of it. I don’t do code completion and I don’t use any of the special bindings or commands. I do like the automatic gofmt and goimports on save though :). Working at Microsoft I feel like I really should be using VS Code but I haven’t been able to pry the Vim safety blanket from my hands yet. The point though is that you could write Go code in notepad if you wanted to. Yes, I realize you can do this with many other languages as well so you don’t have to send me angry e-mails.

Are you bored reading about my love for Go yet? No? What if I told you that you could compile your code to a static binary that anyone could use without any extra shit to install? What if I told you that you could cross-compile your statically linked binary for most of the major operating systems out there without much pain? I really like this part because it makes things so easy to share your app with others. I can write my code on OSX, cross-compile it for my Linux servers and then scp it up there and it just runs. I don’t have to install anything extra, it just works. This of course assumes you are not using import "C" in your code. All hell breaks loose when you do that. Luckily those cases are few and far between for me.

Are you ready for your head to explode? I actually am ok with the fact that Go doesn’t support generics. To me this goes back to my first point about things being readable and easy to understand. I have run into a few cases where the lack of generics was a bit of an annoyance, but I’ve always been able to work around it with a bit of extra code that ended up making everything easier to understand (in my opinion).

Every other “Why I Love Go” post talks about concurrency, but I haven’t really needed to use Go routines too much in my work so I won’t pretend that I have experience with them and ramble on about how awesome they are. Everyone else says they are awesome so I’ll trust them.

Go also has the best mascot of any programming language out there.

Is Go Perfect Then?

Of course not! There have been times that Go has pissed me off, many of those things are well publicized by other Go users (and non-users).

Versioning being in limbo for awhile has hurt. I’ve gone from no versioning to GB to Dep and am about to start kicking the tires on modules/vgo. This has never held me back with regards to writing code, mainly because I try my best to stick to just using the standard library. When I have done versioning of my code I’ve just put a note in the README about what tool the versioning was done with and how to use it. A minor annoyance but nothing I’m going to lose sleep over. Locking this down with what appears will be vgo would be really nice though and likely inspire others to start versioning their dependencies more often.

The binary that Go spits out after it compiles your code can be a bit hefty as well. This isn’t much of a concern these days, but I grew up in the megabytes of memory days so I still tend to get a bit touchy about file size. Having the binary statically linked drastically outweighs the size of the file so I’ll take that trade-off all day long.

A lot of people complain about the whole GOPATH thing, but I honestly don’t care. Again (picking up on the theme here?), I am not a developer and I don’t work with other developers on a team, so having things forced on me like that isn’t a big deal. I’ve yet to run into a situation where I was annoyed by where I had to place my code on my filesystem. I do believe that changes to that requirement are in the works though(?).

Really that is about it. This is not meant to be a “Go is the best ever, you need to use it NOW” type post, it is simply a post on my experiences using Go. My hope is that some of my non-developer friends will read it and give it a try. If it works for you then that’s awesome, if it doesn’t that’s ok too. It is all about using the tool that you feel comfortable with. If that tool isn’t Go we can still be friends, we just won’t be able to use the secret gopher handshake ;).