EMZETT.
Login

Go

In short: A compiled programming language developed by Google — deliberately kept simple, with built-in support for concurrency (goroutines) and very fast compile times.

In more detail: Go deliberately forgoes many features of other modern languages (e.g. inheritance, exceptions in the classic sense), to keep code easily readable and maintainable. Very popular for backend services, cloud infrastructure tools (Docker and Kubernetes are written in Go) and command-line tools.

In Depth

func main() {
    ch := make(chan string)
    go sayHello(ch)
    fmt.Println(<-ch)
}

Goroutines (the go keyword in the example) are Go’s answer to concurrency: extremely lightweight “mini-threads” managed by the Go runtime, of which tens of thousands can easily run at once without overloading the operating system with real OS threads. Channels (chan) are the accompanying means of communication between goroutines — instead of sharing memory with locks (the classic, error-prone approach), goroutines explicitly send each other data via channels.

Instead of exceptions, Go returns errors as a perfectly normal second return value of a function, which the caller has to explicitly check — this feels unusually cumbersome to newcomers, but makes error handling visible at every point in the code, instead of implicit via an exception chain. Go compiles to a single, dependency-free executable, which considerably simplifies deployment — one reason so much cloud infrastructure software (Docker, Kubernetes, Terraform) is written in Go.

Origin at Google

Go was developed at Google in 2007 by Robert Griesemer, Rob Pike and Ken Thompson (publicly unveiled in 2009) — all three with deep roots in Unix and systems-programming history (Thompson co-developed Unix itself). The trigger was frustration over long C++ compile times in Google’s huge codebases, and the lack of a modern language that makes concurrent programming easy from the ground up — both goals still shape Go today: compile times are typically in the seconds even for large projects, and concurrency is a first-class language feature via goroutines rather than a library bolted on afterwards.

Deliberate omission of features

Unusual for a modern language is Go’s deliberate frugality: there’s no classic inheritance (composition via interfaces instead), no generics for the first ten years of the language (only added in 2022 with Go 1.18), no exception handling in the classic sense, no ternary operators. This restraint is an explicit design philosophy: the language designers wanted to prevent different teams within a large company from adopting completely different idioms and styles — Go code from different authors is meant to read as similarly as possible. The built-in formatting tool gofmt reinforces this further, by enforcing a single, non-configurable formatting style for the entire language.

Typical use case: cloud-native infrastructure

Go’s combination of fast compilation, low memory usage per goroutine, and simple deployment (a single binary with no runtime dependencies) makes the language particularly attractive for cloud infrastructure software that itself has to run in large numbers in parallel and start quickly. Besides Docker and Kubernetes, tools like Terraform, Prometheus and etcd are also written in Go — the language has thereby effectively become the standard language of the “cloud native” ecosystem coordinated by the Cloud Native Computing Foundation.

See also: Rust, Docker, Concurrency