Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust
March 2021
Summary: I describe a simple interview problem (counting frequencies of unique words), solve it in various languages, and compare performance across them. For each language, I’ve included a simple, idiomatic solution as well as a more optimized approach via profiling.
I’ve conducted many coding interviews over the past few years, and one of the questions I like to ask is this:
Write a program to count the frequencies of unique words from standard input, then print them out with their frequencies, ordered most frequent first. For example, given this input: