When Go instead of C++, and when not
The question is rarely "which language is better" and usually "which language fits this program, this team and the next five years". The pages of this group measured what can be measured; this one puts the measurements next to the kinds of program people actually write, and says where each language is the better tool. It is not about microservices: a command line tool or a build script is as good a reason to choose Go as an HTTP service.
When Go is the better choice
Command line tools. A Go tool is one static binary per platform, with no runtime to install, and it starts in the same three milliseconds as a C++ one; a release is a file for Linux, one for macOS and one for Windows from the same source. The measured size is 2.4 MB against 18 KB for the C++ hello world, which matters for a tool downloaded a thousand times a day and does not matter for one installed once. The size and startup page has the numbers.
Build tools and code generators. These programs read files, parse them and write files: they are I/O-bound, they change often, and they run on every developer machine and every CI job. A fast rebuild is the whole developer experience, and the measured 109 ms for a Go rebuild against 3.0 s for a small CMake project is the kind of difference a code generator multiplies. Go is also the language the ecosystem already uses for this work, and a tool that other people must contribute to benefits from a language they can read in a week. The build page has the measurement.
Data pipelines. A job that reads JSON or CSV, transforms records and writes them somewhere is mostly waiting and allocating. Go's standard library has JSON, CSV, gzip, HTTP and SQL, its goroutines make a fan-out over files trivial, and the measured allocation cost is 110 ms against 71 ms for a million records, which is a constant factor on a job that takes minutes. C++ wins when the transformation is numeric and vectorisable, or when the records are billions and the per-record overhead is the budget.
Network tools. A proxy, a load balancer, a small DNS server or a webhook receiver fits in one file with net, net/http and crypto/tls. In C++ the same program begins with a choice of an event loop, an HTTP parser and a TLS library, and each choice is a dependency with its own build. The httptest page shows how much of the testing comes for free.
Long-lived internal tools and teams with turnover. An internal service is maintained for years by people who did not write it. Go gives that team one formatter, one test command, one way to handle errors and a language small enough to read in full; the onboarding page measured a sixteen-line C++ diagnostic against a two-line Go one for the same typo. A C++ team can build the same discipline, and the good ones do, but it is a choice each project makes and each new hire must learn.
When it is not
Hard real time. Go's collector is concurrent and its pauses are short, but no document promises a bound a deadline can be built on. A program that must answer within a hundred microseconds, every time, stays in C++ or Rust. The same applies to an audio callback, a game loop and a control loop on a machine.
No collector at all. A program whose memory must be flat, whose peak is part of the contract, or which runs where an allocation can fail, needs manual lifetime. Go's default lets the heap double before a collection, and GOGC trades memory for CPU but cannot remove the collector. The memory page shows what a finalizer costs.
Heavy SIMD and numeric kernels. Go has no intrinsics and its assembly is possible but rare; C++ has intrinsics, vector types, OpenMP and a compiler that auto-vectorises a loop over a std::vector<float>. The measured sort difference, 1.25 to 1.35 times, is small; a BLAS kernel or a codec is not, and that is where C++ earns its complexity.
An existing C++ ecosystem. Qt, Eigen, OpenCV, Unreal, LLVM, a vendor SDK with a C++ API: a rewrite throws away years of work and the people who know it. Calling C++ from Go through cgo works for a narrow interface and costs a boundary crossing per call; the honest answer for a program that is already C++ and whose hot path is C++ is to stay in C++.
The numbers this group measured
| Measurement | C++ | Go | Page |
|---|---|---|---|
| Incremental rebuild, two files | 3.015 s | 109 ms | Build |
| Clean build of the same project | 3.0 s | 11.0 s (empty cache) | Build |
| Hello world binary | 18,504 bytes | 2,392,742 bytes | Size |
| Startup, 50 runs | 2.8 ms | 3.2 ms | Size |
| Sort 10 million integers | 1382 ms | 1705 ms | Performance |
| Hash 64 MB | 136 ms | 138 ms | Performance |
| Parallel sum, four workers | 206 ms | 224 ms | Concurrency |
| Diagnostic for one typo | 16 lines | 2 lines | Onboarding |
The pattern is consistent: a few tens of percent on the CPU, an order of magnitude on the build, two orders of magnitude on the size, and no difference at all on startup or on a parallel loop. None of these numbers decides a project. They say what the constant factor is, so a team can decide whether the constant matters for the program it is writing.
A way to decide
Four questions, in this order. Does the program have a deadline the collector cannot promise, or a memory budget that cannot double? If yes, C++. Does it have to live inside an existing C++ library or engine? If yes, C++. Is the work a network, text, file or coordination job, with the CPU as a small part of the time? If yes, Go is the shorter path and the easier maintenance. And finally: who will read this in three years, and how many of them will there be? A team of two experts can carry C++; a rotating team of twenty is better served by a language with less to know.
The worst outcome is not choosing the wrong language; it is choosing both. A service that is half Go and half C++ because nobody decided costs more than either. If the C++ part is a library, keep the boundary at a narrow interface and a process; if it is a rewrite, finish it. The pages of this group are meant to make that decision concrete: each one has the same task in both languages, built and run, so the argument is about a measurement rather than a preference. Start from the beginning of the group, or from the Go course if the decision is made and the learning begins.
The measurements quoted here were made on Alpine Linux 3.24.3 (x86_64) in a Docker container on an Intel Core i3-6006U at 2.00 GHz with four hardware threads, with g++ 15.2.0 (Alpine 15.2.0), CMake 4.2.3, go 1.26.10 and hyperfine 1.19.0. Each page names the run its numbers came from.
Article author: Arthur Isaev