Sitemap

Member-only story

Rust vs Go for a CLI Tool: 0.3 MB vs 2.4 MB, and the Build-Time Surprise

The same word-frequency CLI in both languages. Rust’s binary was 8x smaller, the run speed tied, and the build times flipped in a way I did not expect

5 min readOct 28, 2026

--

Press enter or click to view image in full size
Press enter or click to view image in full size
Figure 1: The same CLI, built both ways. Rust shipped a 0.3 MB binary to Go’s 2.4 MB, but Go rebuilt in a fraction of the time.

Rust and Go are the two go-to languages for a fast command line tool: one binary, no runtime to install, starts instantly. So which should you reach for?

I wrote the exact same CLI in both: read a text file, count word frequency, print the total and the top 10. Then I measured the three things that actually matter for a CLI: binary size, run speed, and build time. The results were not a clean sweep for either side.

Rust            Go
binary (stripped) 0.30 MB 1.54 MB (2.36 MB unstripped)
run, 17 MB file ~0.10 s ~0.07 s (a tie in practice)
clean build 2.35 s 2.25 s (about equal)
rebuild (1 edit) 2.06 s 0.07 s (Go ~30x faster)

I will be sharing the code, each measurement, and the one tradeoff that explains the build-time gap. Everything ran on an Apple M4 Max, Rust 1.88 and Go 1.27.

--

--

Martin
Martin

Written by Martin

Software engineer writing practical, picture-first guides on Shopify, Node.js, Postgres and React.