Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust
Very interesting, these kinds of articles are (to me) some of the best content we get on here.<p>I&#x27;m no expert in any of the languages used except maybe C, at least I&#x27;m quick to form opinions about C code. In C, I&#x27;m not so sure that there is a well-established &quot;idiomatic&quot; concept, since C is not so tightly bound to a community as more modern languages. At least that&#x27;s my feeling.<p>That said, I was shocked to see that the example code did heap-allocations to store integers. Single integers, one per allocation, per &quot;counting bucket&quot;. I would store the count in the data pointer without a second thought, I just &quot;can&#x27;t&quot; make 4&#x2F;8-byte heap allocations and still sleep at night. Especially after all the concern about processing the input in large blocks for performance! Casting an integer to&#x2F;from a void pointer should be pretty safe according to my gut feel. If that turns out to be false, I would dump the libc&#x27;s hash API altogether, since it makes me do heap allocations to store single integers.<p>I tried making the change locally, and the time taken (as measured with the OP&#x27;s benchmarking program) dropped from 0.11 to 0.10 on my system (a Dell laptop running an Intel i5-7300). That&#x27;s at least something.