HN Hall of Fame Weekly email

Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust

benhoyt.com Essays & writing Essays & articles Software engineering Candidate
Screenshot of benhoyt.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 3 calendar years, with breakout response in 2 of them.

submissions
4
submitters
4
observed span
2021–2024
peak thread · 303 comments
441 pts
latest 20+ return · 2022-07-24
368 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Very interesting, these kinds of articles are (to me) some of the best content we get on here. I'm no expert in any of the languages used except maybe C, at least I'm quick to form opinions about C code. In C, I'm not so sure that there is a well-established "idiomatic" concept, since C is not so tightly bound to a community as more modern languages. At least that's my feeling. That said, I was shocked to see that…

unwind·441-point thread·

Re: the Rust optimized implementation, I was able to get ~20-25% better performance by rewriting the for loops as iterators, using Rust's byte range pattern matching, and a buffered writer, which seems crazy, but it's true. I chalked it up to some crazy ILP/SIMD tricks the compiler is doing. I even submitted a PR[0], but Ben decided he was tired of maintaining and decided to archive the project (which fair enough!). [0]: https://github.com/benhoyt/countwords/pull/115

I know that this is not a golf match, nevertheless, with the OP "this is what I would write in Python in real life" (eliding the module import) being: counts = collections.Counter() for line in sys.stdin: words = line.lower().split() counts.update(words) for word, count in counts.most_common(): print(word, count) I can't but resist to say what I would write in raku in "real life" (all in standard lib btw)... sub MAIN($in) { say $in.words>>.lc.Bag.sort(-*.value); } This is Unicode safe and (imho) gives…

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
819

reference only — not used in Hall rules or ranking

Total comments
525

reference only — not used in Hall rules or ranking

Every submission