Go is a popular programming language used for microservices and concurrency. Thanks to its speed and ease of use, it has been adopted by companies such as Google, Dropbox, Uber and Apple. It was designed by Google engineers and introduced in 2009, which makes it relatively young - and, as a result, not all that well known. We’ve spoken to Rafał, our Go Developer, about the advantages of Go and ways in which businesses can leverage it for the highest possible gains.

Why you should use Go in your app

Rafał, our Go developer, uses Go as his go-to (pun!) language for projects both at work and in his free time. Most of his professional experience involved building microservices and DevOps tools, so he has quite a bit of knowledge on solving various issues with Go’s help. What issues could those be?

Go is definitely useful for companies like Google, Netflix, PayPal, Dropbox or Twitter, as they need to be highly scalable and flexible, to provide a top user experience despite changing expectations, standards and technologies. Go is also the language of choice for Blockchain-based and banking startups. Many companies with existing microservices decide to rewrite them using Go. The ease with which Go supports concurrency (natively, by the way) was very difficult to achieve with other programming languages. (We’ll explain microservices, concurrency and their relationship with Go in detail in the next section of this article.)

If the big names a few lines up don’t convince you that go is a very sensible choice, let us drop some more: Youtube, Uber, The New York Times, Medium, IBM, Twitch, Apple - we could go on. You can read up on why Movio rewrote a part of their system from Scala into Go, or how Iron went from 30 servers to 2 thanks to the language. There’s no question that Go is taking the world of IT by storm.

The two pillars of Go: microservices and concurrency

The two most important concepts that show Go’s full potential are microservices and concurrency. Microservices are an element of modern software architecture, used to decouple applications (i.e. to make them more flexible through removing dependencies between their components). Before the introduction of microservices, application were built according to the monolith model: each component was very closely related to the others. Scalability was an issue, as the only way to do so would be horizontal scaling, which means cloning the entire architecture and adding load balancing on top of it. This approach was expensive and inefficient. Another big advantage that microservices bring is flexibility. Without microservices, an application’s code must have a direct connection to its database. It means that, should the developers ever want to change the database, they’d need to rewrite a good chunk of their code.

The ultimate goal of the microservices approach is the removal of single points of failure and the introductions of more scalable architectures. In practice, microservices allow for communication between an app’s components. They can communicate with each other through the microservice, so whenever a big change needs to be made (e.g. the introduction of a new database), the microservice is where it’s handled. This reduces the amount of time needed for scaling and improving apps. The “micro” in the name is there because a single microservice is responsible for a minimal amount of tasks. Its responsibility is narrowed, so that, should it fail, the lowest amount of components possible will fail with it. This makes modern applications more stable and secure.

According to Rob Pike, one of the creators of Go, concurrency is “the composition of independently executing computations”. It’s an important standard that allows developers to fully utilize all of the cores of their infrastructure’s processors - without writing extremely complex code to handle it. Before concurrency gained the popularity it has today, businesses had to expand their infrastructure (i.e. buy more processing power) rather than efficiently use what they already had. Go used the concurrency model (which is not a new concept) and made implementing and using it much more simple and cost-effective.

The pros and cons of Go

To help you evaluate how Go can help your business, and whether it’d be worth it to rewrite code written in another language, we’ve prepared a list of the advantages and disadvantages of Go.
Pros

  • It forces a single code formatting style, which boosts productivity as time is no longer wasted on merges and teamwork is improved;
  • Go has a low barrier to entry, which means you can quickly introduce it to your team;
  • It’s a very fast language (also for compiling);
  • It supports testing natively;
  • New versions of Go guarantee backwards compatibility;
  • Go has a trove of useful libraries (some within the official Go repository, built and supported by the language’s creators);
  • The direction of Go’s growth is based on the opinions and needs of its community, which makes it a safe and stable technology;
  • Go compiles on almost all architectures (e.g. on Raspberry PI);
  • It doesn’t allow for the retention of unused variables or the import of unused libraries, which greatly improves code quality;
  • Go is supported by the most popular code editors, which makes it easy to use by any team;
  • It supports modularity, which makes library sharing more effective within projects.

Cons:

  • Go’s core team did not enforce one standard of maintaining package dependencies. They addressed this in version 1.11, which shows that they hear the community;
  • Go has small issues with code readability, like the convention to use one letter names for variables.

As you can see, the disadvantages of Go are few and largely subjective.

Our experience with Go

Before Rafał started his adventure with Go, he was interested in Erlang because of its fantastic support for concurrency and fault-tolerance. Sadly, Erlang wasn’t the best tool for building web or computation-heavy projects. Rafał searched for something that had Erlang’s advantages and could be used for web apps. He discovered Go, which not only supports concurrency, but also the generation of HTML templates and hot deployment (achievable through Kubernetes which, incidentally, is built with Go). Rafał soon realised that Go has a wealth of web libraries, which he found extremely useful as a DevOps engineer.

Go is a pragmatic solution to common - and often crippling - problems. It’s easy to learn, and fits nicely into a minimalist approach. There are also few reasonable alternatives.

  • Erlang is a great language, but Go is superior for arithmetic computations and image processing. A program written in Go is also more portable than an Erlang app - it doesn’t need a virtual machine.
  • Go is “closer to the metal” than Scala, and it compiles to platform dependent code (amd64, i386). The syntax is a way simpler, too.
  • Rust has a steeper learning curve than Go, which could be part of the reason why Go is more popular and much better supported by its community.

Does Go sound like the technology you need to improve your business?
iRonin’s experts pride themselves on delivering technical excellency and fully optimized code.