Rust vs Go: Which Language Wins in Speed and Code Size?
The author compares Rust and Go using a series of micro‑benchmarks across common algorithms, presenting CPU time, elapsed time, memory usage and code size, and concludes that while Rust is roughly 30 % faster, Go produces about 30 % less code, making it a better choice for enterprise applications.
Background
The author, with over ten years of C++ experience in telecom systems, explores the differing evolution of Rust and Go and their suitability for various domains. Rust is positioned as a successor to C/C++ for high‑performance, low‑level workloads, while Go is seen as an alternative for developers coming from Python, Ruby, or Java, targeting enterprise and server‑side applications.
Benchmark Methodology
A set of micro‑benchmarks from a publicly available language benchmark suite was used to compare the two languages. For each program the author recorded CPU seconds, elapsed seconds, memory consumption (KB), compiled code size (bytes), and approximate CPU load percentages.
Individual Benchmark Results
binary‑trees : Rust – 22.05 CPU s, 5.97 elapsed s, 228 196 KB, 788 B; Go – 68.41 CPU s, 18.42 elapsed s, 266 624 KB, 814 B.
pidigits : Rust – 1.73 CPU s, 1.73 elapsed s, 5 308 KB, 1 297 B; Go – 3.76 CPU s, 3.52 elapsed s, 3 668 KB, 674 B.
spectral‑norm : Rust – 7.87 CPU s, 2.06 elapsed s, 5 112 KB, 1 020 B; Go – 15.70 CPU s, 3.96 elapsed s, 1 816 KB, 536 B.
reverse‑complement : Rust – 0.74 CPU s, 0.49 elapsed s, 257 160 KB, 2 015 B; Go – 0.93 CPU s, 0.77 elapsed s, 250 564 KB, 1 243 B.
fasta : Rust – 4.99 CPU s, 5.00 elapsed s, 4 812 KB, 1 224 B; Go – 7.26 CPU s, 7.27 elapsed s, 1 028 KB, 1 036 B.
regex‑dna : Rust – 35.26 CPU s, 11.95 elapsed s, 228 296 KB, 763 B; Go – 47.40 CPU s, 16.27 elapsed s, 543 868 KB, 789 B.
fannkuch‑redux : Rust – 50.01 CPU s, 12.81 elapsed s, 7 072 KB, 1 180 B; Go – 67.16 CPU s, 16.86 elapsed s, 1 032 KB, 900 B.
mandelbrot : Rust – 20.14 CPU s, 5.09 elapsed s, 56 824 KB, 1 290 B; Go – 25.44 CPU s, 6.39 elapsed s, 32 276 KB, 894 B.
n‑body : Rust – 20.99 CPU s, 20.99 elapsed s, 4 824 KB, 1 371 B; Go – 22.95 CPU s, 22.95 elapsed s, 1 036 KB, 1 310 B.
k‑nucleotide : Rust – 26.06 CPU s, 9.76 elapsed s, 152 536 KB, 2 113 B; Go – 30.93 CPU s, 8.42 elapsed s, 251 024 KB, 1 399 B.
Aggregated Results
By averaging the elapsed times and code sizes across all benchmarks, the author obtained:
Rust – average elapsed time ≈ 7.585 seconds, average code size ≈ 1 306 bytes.
Go – average elapsed time ≈ 10.483 seconds, average code size ≈ 960 bytes.
Conclusion
The micro‑benchmarks indicate that Rust is roughly 30 % faster than Go but requires about 30 % more source code to achieve the same functionality. Considering modern hardware trends and the rising complexity and maintenance cost of software, the author recommends Go for enterprise applications where development speed and lower code volume are advantageous, while acknowledging Rust’s performance edge for low‑level, high‑throughput systems.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Art of Distributed System Architecture Design
Introductions to large-scale distributed system architectures; insights and knowledge sharing on large-scale internet system architecture; front-end web architecture overviews; practical tips and experiences with PHP, JavaScript, Erlang, C/C++ and other languages in large-scale internet system development.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
