A detailed performance comparison of word-frequency counting programs implemented in Python, Go, C++, C, AWK, Forth, and Rust. For each language, both a simple idiomatic solution and a profiler-guided optimized version are presented. Key optimization techniques include reading input in 64KB chunks instead of line-by-line, custom hash tables with FNV-1 hashing, ASCII-only lowercase conversion, and reducing memory allocations. The C optimized version is fastest, followed closely by optimized Go and Rust. Profiling tools covered include Python's cProfile, Go's pprof, Valgrind Callgrind for C, and gprof for C++. Community contributions added implementations in over 20 additional languages.
Table of contents
Problem statement and constraintsPythonGoC++CAWKForthRustUnix shellOther languagesPerformance results and learnings1 Impression