Monday, January 22, 2018

Why Golang?

After some time working with Go Programming Language (also known as Golang) I decided to ask myself "why go?". OK... I have searched "why golang", if you are a Go programmer you know about the difficulties to use the "go" term on searches.

This language became part of my life after taking a job change decision to work on another company. The new company's engineering team was using Go as its main programming language. I did not ask myself about this point earlier because I believed in the strengths of each member in the new team (I already knew about the excellence of developers at Tempest Security Intelligence) and also had curiosity to learn a new language. I joined the crew and navigated as commanded, until now.

Just to make it clear before starting, I am not dissatisfied with Golang. The question came most in a manner to answer myself why I have never used it before. In my opinion, it is an excellent programming language to write a backend API serving over HTTP and also to create some Unix based tools. Some years after its creation, Go is becoming so popular that many companies in Brazil (such as Mercado Livre,, Magazine Luiza, and Walmart) are changing their backend solutions to use Go instead of other languages.

Previously I have worked with several different programming languages using many different tools. In this way, I know that Go has a lack of good free tools for developers. But in my opinion the language itself worths, even without some fancy tools. I was never (and I am still not) a programming language fanatic, only took what was better for each situation or, sometimes, what was a client request. Even that I am really satisfied with Go, it is not a love letter.

Golang may appear more verbose when compared with some other languages, but its simplicity makes it easy to learn (mainly for Java and C programmers). Dave Cheney reported about Golang simplicity and also mentioned that "what makes Go successful is what has been left out of the language, just as much as what has been included". Given my experience with Java, I still miss some functionalities such as annotations to ease on my API definitions, but the usage of middlewares allow me to live in peace without them.

Even raising my points, I will not extend in the explanation of each benefit that makes me accept Go as a good language for a backend API. There is a lot of texts talking about the subject and sometimes comparing with another languages. Enjoy yourself:

Getting back to my personal experience, some of the most valuables benefits of Go usage are: possibility to deploy with just binary replacement, easily perform communication between processes using channels and goroutines, and its error handling structure makes a very clean code. Golang also has pointers, making it fast to note when something is value or reference, but also has garbage collection, allowing developer to live well without freeing memory.

But what is most valuable for me is that Go has a very simple subset of standard libraries focused on some nowadays problems. To illustrate better, lets listen on a port 8080 to provide some web content:
import (
func main() {
      func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Here goes my HTTP response...")
  http.ListenAndServe(":8080", nil)
That is it, no web container, no necessary runtime dependency, no server. Just build, deploy, and run. At the end, Go simplicity is the key feature I believe that is necessary to deliver good products.