Programming language · 2009
Go
Programming language developed by Google and the open-source community.
Official site ›What is Go written in?
What Go is used for
Go is built for cloud infrastructure and networked services: its fast compilation, simple concurrency (goroutines), and single static binaries make it ideal for servers, CLIs, and DevOps tooling.
Notable software: Docker, Kubernetes, Terraform, and much of the modern cloud-native stack are written in Go.
About Go
Go is a programming language developed by Google and the open-source community. It is a statically typed and garbage-collected language that compiles ahead of time to native machine code. It supports imperative and concurrent programming.
Go first appeared in 2009 and was designed by Rob Pike, Ken Thompson, and Robert Griesemer at Google. Go has a large, active user base today.
Go in the language family tree
Go drew on ideas from Newsqueak, Limbo, Alef, Oberon-2, and Oberon and went on to influence V, Crystal, and Odin.
Sources: Wikipedia · Wikidata · Official site
Quick Facts
- Short answer
- Go compiler and runtime are written in Go
- Self-hosting since
- Go 1.5 in 2015
- Before Go 1.5
- Compiler written in C
- Low-level pieces
- Some assembly remains
Go before and after Go 1.5
The original Go toolchain was written in C. Robert Griesemer, Rob Pike, and Ken Thompson designed Go at Google beginning in 2007, and the first open-source release in November 2009 shipped with a C compiler. Using C was pragmatic: the team were C experts, the Go runtime and scheduler concepts were familiar in C, and writing a new language's first compiler in C is the conventional bootstrapping path.
The move to a self-hosted compiler was deliberate and methodical. In 2013, Russ Cox created a tool that mechanically translated the C compiler source to Go, producing a Go compiler that was syntactically Go but still structurally a C program. That automatically translated compiler was the foundation for Go 1.5's compiler, released in August 2015.
Go 1.5 removed the C compiler entirely from the toolchain. The build system no longer required a C toolchain: you only needed a prior Go binary to bootstrap. The same release also moved the runtime's garbage collector and scheduler from C to Go, significantly improving the ability of Go contributors to understand and modify the runtime. The Go garbage collector, written in Go since 1.5, received major improvements in 1.5 (concurrent), 1.8 (sub-millisecond pauses), and 1.14 (preemptible goroutines).
Go runtime architecture
The Go runtime is written in Go and a small amount of assembly, and provides three major services: goroutine scheduling, garbage collection, and low-level primitives for the standard library.
Goroutines are Go's concurrency primitive. They are multiplexed onto operating system threads using an M:N scheduler. The scheduler's model has three entities: M (OS thread), P (logical processor, controlled by GOMAXPROCS), and G (goroutine). Each P holds a local run queue of goroutines and draws from a global run queue when its own is empty. Work stealing lets an idle P take goroutines from a busy P's queue, keeping all available OS threads occupied.
Go's garbage collector is a concurrent tri-color mark-sweep collector designed for low-latency applications. The collector runs concurrently with the program during the mark and sweep phases and stops the world only briefly to acknowledge marking completion and to flip the write barrier state. Goroutine stacks start small (a few kilobytes) and grow by copying to a larger allocation on demand, which allows starting hundreds of thousands of goroutines in a single process without pre-allocating large stacks.
Go implementation layers
| Layer | Written in | Notes |
|---|---|---|
| gc compiler (go tool compile) | Go | Self-hosted since Go 1.5 (August 2015) |
| Original compiler | C | Used before Go 1.5; mechanically translated to Go in 2013 to 2015 |
| Runtime (scheduler, GC) | Go and assembly | Concurrent GC, goroutine scheduler using the GMP model |
| Standard library | Go | Nearly all pure Go, with small assembly stubs for atomic operations and syscalls |
| gccgo | C++ | Alternative Go frontend for GCC; less commonly used than the gc compiler |
Go release history
Go was designed by Robert Griesemer, Rob Pike, and Ken Thompson at Google starting in September 2007. The initial goal was a language that addressed frustrations with C++ build times and Java's verbosity while retaining C-like simplicity. Go's concurrency model drew from Tony Hoare's Communicating Sequential Processes (CSP), which Rob Pike had previously explored in the Newsqueak and Limbo languages.
Go was open-sourced in November 2009 under a BSD-style license. Go 1.0 shipped in March 2012 with a compatibility guarantee: source code written for Go 1.0 would continue to compile on all future Go 1.x releases. That promise has been kept without exception.
Key releases: Go 1.5 (August 2015, self-hosted compiler and concurrent GC), Go 1.11 (2018, module system replacing GOPATH), Go 1.14 (2020, asynchronous preemption for goroutines), Go 1.18 (March 2022, generics via type parameters, the biggest language change since 1.0), Go 1.21 (August 2023, built-in min, max, and clear functions, WASI preview), Go 1.22 (2024, loop variable semantics corrected). Go ships two releases per year, in February and August.
Frequently Asked Questions
Evidence Sources
- https://go.dev/doc/faq#history
- https://go.dev/doc/go1.5
- https://vlang.io/
- https://devblogs.microsoft.com/typescript/typescript-native-port/
- https://en.wikipedia.org/wiki/Go_(programming_language)
- https://en.wikipedia.org/wiki/Crystal_(programming_language)
- https://en.wikipedia.org/wiki/Odin_(programming_language)
- https://en.wikipedia.org/wiki/Esbuild
- Go on Wikidata (Q37227)