Tech & Engineering
min of reading
July 9, 2020

But why Go?

Morvana Bonin
Backend Software Engineer with a strong passion for design patterns, clean code and software architecture.
More about the author

* article elaborated in partnership with Andreia Camila da Silva

The previous post introduced a notion of the language and where to start your studies in Go. In this post, we will give you the reasons to use Go.

Before listing the reasons, let's take a look at some results from the 2020 edition of the Developer Survey, conducted by Stack Overflow. Go is ranked 12 in the most popular technologies ranking.

Nevertheless, it is among the 5 most loved languages of the year.

The survey shows a very interesting contrast. It seems Go has not yet gained a comprehensive share of the market. At the same time, it is among the most loved and desired languages by developers. This article aims to list some interesting features of what may become your favorite language. So, hey ho, let’s Go!

  • Easy to learn

Go has a lean and simple syntax, with few keywords to memorize, enabling rapid learning. Even for developers used to other languages like Java and C, Go presents a shallow learning curve. It's the kind of language that makes the programmer read a book or the documentation itself and wonder: "But is that all?"

  • Compiled Language

It is common to hear that Go is a fast programming language. One of the reasons is that the code developed in Go is translated by the compiler into native machine code, generating considerably small binaries. The Go compiler is very effective in detecting pre-compilation failures and even preventing possible "waste" such as variables or unused imports. There is no need to use VMs.

  • Cross-platform or cross-compile

It is possible to generate Go code executables for several platforms through the $go build command, informing the operating system and target architecture through the GOOS and GOARCH environment variables. This way, the source code will remain intact.You can also cross-compile your application into a docker container, check out here.

  • Garbage Collector

Garbage Collector will reclaim memory occupied by objects that can no longer be referenced within the scope of execution. It is processed simultaneously, during the execution of the Go program.

  • Simultaneity

Go has very efficient and lightweight support for simultaneous code execution through goroutines and channels. Goroutines are analogous to threads, but at a considerably lower cost. To create a goroutine just add the keyword go before the desired function is called (or through anonymous functions). This will cause it to be executed as usual, but the program will not wait for a response before proceeding to the next instruction. The channels, on the other hand, make communication between goroutines possible, allowing the exchange of values between them through the send and receive operations.

  • An interesting option for cloud

As mentioned in the previous post by Morvana Bonin, several cloud technologies have their core developed in Go. This is something that leads us to believe that the language is not only suitable for cloud development, but also composes it. In this interview, Steve Francia, Product and Strategy Leader of the Go language, comments that "It would be reasonable to say that the modern cloud is written in Go". Another advantage is the Go Cloud Development Kit, which provides APIs that assist in the development for major cloud providers.

A brief summary of why to use GO

Go has an attractive range of features, which can also be found in other languages, but are not always combined. On the other hand, because it values simplicity, it does not have certain conveniences such as exceptions, generics, overload of functions, inheritance or annotations. In the book Go In Action, the author mentions that "Go is not only defined by what it includes, but by what it does not include". It is with this thought that we come to the end of this article.

References and useful links

subscribe to our newsletter with exclusive content.

Click and join the Sensedia News!

Click and join the Sensedia News!

Click and join the Sensedia News!

Thanks for reading!