Google's Go Language

Google’s Go Language, and Why You Should Learn It

Go, also known as Golang, is a relatively new programming language that was initially released in late 2009.

Since then it has accumulated impressive adoption and acceptance by the developer community due to a few of Go’s characteristics that make it a great programming language for efficiency in the cloud – is its primary domain.

Table of Contents

The Problems Go Fixes

Google’s Go was born out of frustration at Google, whose engineers were finding increasing challenges in building and maintaining their cloud infrastructure.

The main problems that inspired Go were:

  • Increasingly complex codebases to handle concurrent processing in the cloud, an essential component of efficient and scalable services, virtual machine infrastructure and online system programming in general.
  • The use of multiple programming languages that further fragment codebases. Go can replace Java, C++ and even Python code, which are its main competitors.
  • Long compile times.

Go was designed to fix these problems, and as such has three flagship features that make developing applications easier:

Fast concurrency, with simple APIs

Go abstracts complex concurrency logic into the compile process, and offers simple APIs such as its Goroutines (efficient multi-threading with the go keyword) and select statement to simplify  parallel processing.

Go was designed to run on multiple cores and to handle large-scale concurrency as more cores are added – and this is what makes Go attractive for cloud services.

Efficient, compiled language with garbage collection

Go is also fast and very efficient, rivalling or beating Java in many benchmarks.

Its speed and efficiency can potentially save time and money in the cloud, as not only are tasks processed very efficiently, a well-designed program that leverages concurrency will mean tasks will complete even quicker.

It is important to note that Go is a compiled programming language (compiled languages are transformed into native machine code) that comes with a garbage collector, so it will therefore be faster (generally speaking) than competitors such as Python or PHP.

Go will lack benefits found in an interpreted language however, like rapid prototyping and ease of debugging.

Developers can write programs with Go for a range of use cases, from command line tools to heavy data processing for both web apps and mobile apps.

Open source programming language with multi-platform support

Developers are further incentivised to learn Go by its simple syntax. Static typing and opinionated syntax make Go easy to read – every Go program’s source code should conform to a standard set of code conventions.

On top of this, Go is open source and fully compatible with Linux, Windows and Mac operating systems, with support for all major chip architectures.

Ensuring Go programs are compatible for all major platforms and hardware architectures has been key to its success, further complementing its strengths already mentioned.

So where does Go stand in 2021 after 12 years of well-documented language development? Let’s find out.

Go vs Other Programming Languages

Go vs Other Programming Languages in 2021

Recent developer surveys highlight that Go is standing strong as an attractive programming language for most developers, who are primarily programming for the back-end web in 2021.

This adds further relevance to Go’s proposition – and recent developer surveys have clearly highlighted this.

Go is a fast-growing programming language

The Jet Brains: The State of Developer Ecosystem 2021 survey finds some encouraging statistics for Go’s prospects.

Not only is Go present in the top-5 languages developers are planning to learn or migrate to, it is also in the top-5 languages that developers are learning now in 2021.

Not only this, Go sits in the list of 5 fastest growing languages – with this being no surprise given the previous two statistics.

Go is a fast-growing

17% of developers used Golang in the past 12 months [Q3 2020 – Q3 2021], whereas 11% are planning to adopt or migrate to the language.

These figures vastly outpace those of Rust (another relatively new programming language and Go competitor) that was at 6% and 7% respectively.

Go is relevant in a back-end web dominated market

Another reason Golang is relevant now is the shift towards back-end web development that now dominates the primary role of developers.

As a matter of fact, 71% of developers develop for the back-end web, with this field encompassing the cloud infrastructure for popular services today ranging from online gaming, video streaming services, mobile app infrastructure, and more.

Where companies are looking for the most efficient means of running a service (both for developing and executing), Go will be a prime candidate as the programming language of choice.

However, it still faces steep competition from JavaScript, Java, Python, PHP, and C++, which are still massively more popular than Go.

Go popularity

Go is still niche, but has high interest amongst developers

The popular Stack Overflow developer survey also paints quite a positive picture for Go, although it strongly highlights that developers still opt for the more popular languages – JavaScript, Python, Java, etc – in most cases.

Only 9.55% of respondents to the Stack Overflow 2021 survey edition use Golang – with the closest competitors, Java at 35% and  Python at 48%, being far more widely used.

In addition to this, Go is in a respectable 10th position as the most loved language, but still had a “dreaded” language response of 37.5% – a rather high rating.

These stats suggest many developers are still on the fence when it comes to learning Go – but many do desire Go with the language being ranked number 4 as the most wanted language.

There is clearly interest in Go, but also a clear pressure programmers are facing with the prospect of learning yet another programming language, that may be slowing its growth.

Developers who use Go are very satisfied

Another valuable resource is Go’s own developer survey, which gauges the opinions and views of developers who are already using it.

The 2020 results clearly show Go is doing a great job in keeping its developers happy – here are some key statistics from the survey:

  • Two thirds of respondents believe Go is critical to their company’s success. This suggests Go can do things that other  languages lack, and this gives a competitive edge.
  • 92% of respondents are satisfied with Go. What is important to note is that Go is constantly evolving, that is partly due the open source nature of community lead feedback.
  • There are approximately 1.1 million developers who use Go as their primary language, with that figure doubling when you consider developers who use Go as a secondary language.

Even though Go is not as popular (in terms of adoption) to Java, C++ or Python, it is clearly on an upwards trajectory, and is therefore very likely Go will continue to gain market share as requirements for more efficient cloud computing increases.

Go and Concurrency

Go and Concurrency

A programming language that supports concurrency allows programs to execute multiple things at the same time – this is also known as multi-threading.

Concurrency is a feature that programming languages have historically not supported to a high standard, mostly due to the most popular ones being designed before large-scale, multi-core cloud computing took off.

JavaScript for example was designed in 1995, with support for async and await coming in ECMAScript 2017.

JavaScript itself is a single-threaded language, with the runtime environment (the JavaScript engine) handling this asynchronous support.

PHP (also 1995) is single threaded, and notoriously hard to scale. There have been attempts to support asynchronous execution with PHP, but these are far from efficient, elegant solutions.

Python supports some multi-threading constructs via its threading API, but again, this is far from a complete solution suffering from common pitfalls with concurrency.

These common problems, that are common across programming languages, include:

  • Starvation: a scenario where a thread is unable to gain regular access to shared resources and is unable to make progress
  • Deadlock: Occurs when a thread is waiting for another thread to finish, and vice versa.
  • Livelock: Similar to a deadlock, except that the states of the processes involved in the livelock constantly change with regard to one another, with none progressing.

Go attempts to avoid these issues by considering concurrency from its inception.

The concurrency features Go offers are fast, efficient, and baked directly into the language syntax with keywords and operations that are managed under-the-hood.

Go Concurrency Features

Go Concurrency Features

There are three main concurrency features to study with Golang:

Goroutines

Goroutines are functions that are run independently to the function that called it, effectively allowing multiple processes running simultaneously.

Calling a Goroutine is just like calling a standard function that runs in the main thread, but with the go keyword before the function.

The Golang docs host a great intro to Goroutines with simple examples. Goroutines are Go’s foundational building blocks for concurrency.

Channels

Channels are pipelines that allow data to be sent and received between Goroutines. This effectively allows concurrent processes to communicate between each other, controlling their execution flows based on the events of each Goroutine.

As channels are natively supported in Go, the implementation is fast and reliable – the chance of deadlocks or starvations dramatically decreases with this reliability.

Check out the concurrency tour of Go to find out more about channels.

go example2

Select Statements

Expanding on the concept of channels, Select Statements in Go allows a particular Goroutine to wait on multiple communication operations:

go example3

Select statements can efficiently combine multiple Goroutines and multiple channels to create logic for a concurrent program that considers every source of data, and every process state.

Go by Example hosts a simple Select example that communicates the idea clearly.

For more information on concurrency with Go, Golang Programs offers a more detailed resource for exploring these features in more detail.

Where Go is Used

So having understood a lot about Go’s characteristics, where it currently is at in terms of adoption, and how it stands out from other programming languages,  where can it be found in production applications?

Concretely, Go is used in three main fields:

  • IT services, ranging from file storage, email solutions and application backends that require efficient scaling.
  • Finance and FinTech: Digital banks have adopted Golang, and so have notable blockchain protocols (the most popular Ethereum implementation, go-ethereum, is written in Golang).
  • Cloud computing, particularly within Google’s own cloud platform and SDK offering.

These are the kinds of applications Go is best suited for; Go mainly lives on the server-side.

To get a feel for what Go can offer, the Awesome Go repository on GitHub has been set up, acting as a curated list of Go frameworks, libraries and software (their website is also maintained).

The full Go Modules archive can be browsed on pkg.go.dev. Go Modules has become the preferred means of package management with Go, providing developers tools to share and access reliable source code libraries.

Go at Google

Go at Google

Perhaps unsurprisingly, the Go language is well integrated into Google Cloud Platform (GCP). Ever since the commonly referred to engineers from Google (Robert Griesemer, Rob Pike, and Ken Thompson) designed Go, it has been widely used within Google’s own infrastructure, and is part of what makes GCP as capable as it is today.

Not only is Google Cloud built on Go, Google has provided a full set of APIs for accessing GCP services programmatically using Go. 

It is also their recommended way of accessing Google Cloud amid their SDK support for of host of other languages, as Google publicly discuss:

“The Cloud Client Libraries support accessing Google Cloud services in a way that significantly reduces the boilerplate code you have to write. The libraries provide high-level API abstractions so they’re easier to understand.

They embrace idioms of the language, work well with the standard library, and integrate better with your codebase.” – Google Cloud Docs

There is also some fantastic documentation Google provides, from training courses, tutorials and code examples, that make integrating Go an increasingly seamless process. Online command line tools also provide interactive walkthroughs for developers.

Tech Platforms Using Go

Notable technology platforms that adopted Go early on include SendGrid and Dropbox. Dropbox have been public with their use of Go, first adopting it in 2014 as a migration from Python to bolster their efficiency and scalability:

“Dropbox owes a large share of its success to Python, a language that enabled us to iterate and develop quickly. However, as our infrastructure matures to support our ever growing user base, we started exploring ways to scale our systems in a more efficient manner.

About a year ago, we decided to migrate our performance-critical backends from Python to Go to leverage better concurrency support and faster execution speed.” – DropBox Blog

Around the same time, SendGrid also shared their migration to Golang, which would act as their primary programming language:

“One of the most compelling reasons for using Go at SendGrid is having the concept of concurrent asynchronous programming as part of the language.” – SendGrid Blog.

FinTech Companies Using Go

Go has been used by Monzo Bank, which has built their banking system from scratch. They adopted Go to build their system for “hundreds of millions of customers”, which entails huge scaling up and down as traffic to the service peaks or levels off. They had this to say in their on their blog:

Go makes it easy to build low-latency, high-concurrency servers, but no one language ecosystem has everything we need to build a bank.” – Monzo Blog.

So while Go does not offer the full solution for Monzo (and shouldn’t be expected to, with capable ecosystems in JavaScript, Python and others), this use case does highlight that Go can be embedded within an existing codebase, and that migration can happen seamlessly for a large organisation.

Capital One has posted about their serverless infrastructure with Golang too on Medium.

In the broader payments space, PayPal, and American Express have integrated Go, highlighting its capabilities in payment processing systems.

Booking and Ride Sharing Platforms using Go

In the online booking space, Uber, Sixt and Trivago have  publicly commented on their Go migrations. Bolt also relies on Golang for their Bolt Payments solution, having created a library called Sleet, allowing developers to interact with different payment providers.

This list would indeed become quite exhaustive if we continued to explore Go’s integrations.

Needless to say, where larger platforms require efficiency, reliability and simplicity (aligning with Go’s slogan on their homepage), there is a good chance it is being used in such efforts – and this is why developer surveys are favourable towards Go.

The Future of Google's Go

The Future of Google’s Go Programming Language

So what can we summarise from the Go language in 2021 amid an extremely competitive landscape of programming languages, some of which are far more adopted than Go?

Well, the data suggests the relatively young programming language is on an upwards trajectory in terms of usage, satisfaction and even its capabilities – with Go 1.18 features being recently posted.

Generics and workspaces are two standout features coming to the next version of Go, and can be experimented with today.

From a technical standpoint, Go is the standout offering for server-side applications with its native concurrency support and efficient execution, along with garbage collection to keep memory leaks at bay.

Go is an open source programming language with multi-platform support that further bolsters its proposition.

Existing infrastructure is Go’s main opponent in building more market share, with its main competition coming from Python, Java, JavaScript and C++ all already having a strong foothold in web services.

As we have discussed, Go has been an integral part of codebases of many large organisations for a number of years, ranging from cloud platforms, banks and other fintech applications. Some of these migrations stem back to the early stages of the language.

Google, being the main contributors and most notable cheerleaders of Go, deeply support the language throughout Google Cloud Platform and their SDKs, showing that Go is fully capable of  high performance, efficient software development.

Overall, the Go language is worth considering learning for a market that predominantly looks for web service engineers – it is a relevant programming language that developers can leverage, both as a primary and secondary language.

Google Go and Iglu

Outsource Cloud Engineering with Iglu

With over 10 years of experience in the industry, Iglu has a track record of attracting talented data science specialists from all over the world.

Our Enterprise-grade employees range from senior talents with decades of experience to junior employees for more affordable solutions.

Not only are we experts with the mainstream tech stacks, but we also have specialists in some of the most exotic programming languages.

See our comprehensive list of services for more information and we will look forward to working with you.

Ross Bulat