Why Go ( Google’s programming language, or golang)

Marcos Tocchetto Pires
5 min readJan 22, 2018

--

This will be the kickoff post in a three post series about Go, for a class I am currently taking at SAIT.

After searching a couple job posting and juggling a couple of ideas around I saw Go, and it wasn’t the first time that I’ve heard of it and I thought “Well now, this seems like the perfect topic. It is a new language, it seems very interesting and I’ve thought about learning it before”, so here we are.

OK, now on to the more concrete reasons of why to choose Go if you are looking for a programming language to learn.

If you go (the puns are unavoidable) to Go’s GitHub page there’s a section on the wiki about the Go users, the companies *around the world* that are using Go and apart from the trendy start ups you have big names like Walmart, Comcast, Facebook, IBM, Dropbox, New York Time, Medium and, you guessed it , Google, among many others.

If you are looking for something to prop up your resume, the big companies using it and looking for people who knows it is a good enough reason, but alas we are only human and would like more reasons to learn it, after all you like programming, so sure enough there must be a nerdy reason out there that tickles your fancy.

Lets then dive into the more technical aspects of Go:

  • It is a compiled language
  • Explicitly declared
  • Statically AND Dynamically typed (What!?!?)
  • Looks like C…
  • … But is memory safe ( No more malloc yey!)
  • Free and open source
  • Built for concurrency(?!)

On my following posts I will explore in more depth the pros and cons of Go, better explaining most of the list above, but here is a very quick explanation of most of it.

Compiles Language

Before executing a Go code, it must be transformed to machine code, that is the compile. For contrast, Java don’t do this, kinda. Java first compiles the code to bytecode, which is then understood by the JVM and compiled into machine code. This level of abstraction has advantages but also make it slower. In sum, a code that is directly compiled to machine code, is less portable but faster.

Statically and Dynamically typed

Whaaaat?! And I really mean it. First time I saw that my brain got all jumbled up and took me a while to understand it. Basically you have Strong or Statically typed languages, like Java, where you must say the variable type, like int x , here we are explicitly saying that the type of x is int. Then you have Loosely or dynamically typed languages like JavaScript where you just say var x like a dirty peasant and the language figures out, infers, the variable type based on what you put on said variable. Well guess what, now you can do both with Go, you can either declare the type or not, no rules anymore, up is down and down is up.

I will provide more details and examples on this very interesting feature of Go on the next posting, stay tuned.

Looks like C

There was a clear intention behind that. Think about how many hundreds of programming languages there are out there, I usually find myself going “Oh god do I have to learn ANOTHER language from the ground up?” and I bet I am not the only one.

This was the intention behind the C likeness, to make Go a quick language to pick up… If only my C wasn’t so rusted.

Free and open source

Are you sad that you lose the dawn of the computes and think you can’t make any meaningful contribution to systems like Linux or some other open source thing because all the good things were already said? Your problems are over! Now presenting Go’s contribution guide! But serious now, it is very cool the openness the developers are taking in that front. If you know of a way to improve the language you can follow the contribution guide, provide your problem/solution, probably jump through a couple hoops and done!

All very nice and dandy but WHAT is Go for?

My feelings as I research Go is that is not your next Java or C#, although it was designed to be an alternative to C++, it is not supposed to be a jack of all trades language, but a specific language to solve specific problems.

Through it built in concurrency and web server functionalities one can see that Go is its element when you are dealing with cloud system and distributed services.

How to learn Go

OK, you are clearly already interested and need to know how to learn more about this awesome language that I so poorly explained.

Since Go doesn’t come shipped with whatever OS you are using, you must first download and install it following the instructions here.

Below is a list of learning resources for Go:

  • Go By Example — literally what it says, it provide several examples and explanations of Go
  • How to Write Go — A guide in the official website with very interesting information about Go’s structure
  • The Go programming language — Because you are not a real programmer if you don’t have a thick reference book to read while on the can.
  • Gopher on Slack — A social platform like Discord or IRC, to talk to other people about the language, if you are into this sort of thing.

By the way, that is why the language mascot is that blue thing, its a gopher hahaha, because that’s what Go programmers call themselves got it?! hahah….

Anyway, this is not by any means a complete list of resources but should get you on your way. As always Google search and Stackoverflow are your best friends.

A little more on the idea behind Go

After reading Rob Pike’s simplicity is complicated slides, I would like to present here one idea from him that really hit home with me.

Language convergence

He mentions something that I agree if you think about it for a while, many programming languages take features from one another, essentially they are becoming the same language and this is bad because if all languages are the same, you have a limited number of ways to look at a problem.

Here is an example. If I give you a hammer, a nail and some plank, the only way you can put them together is by hammering the nail in the plank, nice. But what if we had another tool kit, one with glue instead of hammers and nails? Now we have a whole different way of putting those planks together and guess what, each method is more or less advantageous depending on the situation( I am no contractor so I will drop this metaphor here). I think this is exactly what he is referring to, if all languages provide you with the same tools, you might not always be able to find the best approach to a problem, that is why Go purposefully left out a lot of “features” from other languages, because it is an specific language for specific tasks.

Well, this is it for now, hope it was a fun read and hold on while I research and prepare for the next two posts on pros and cons of Go.

--

--