Performance comparison: counting words in Python, Go, C++, C

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


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:

Related Keywords

, Anton Ertl , Jon Bentley , Andrew Gallant , Mike Haertel , Donald Knuth , Raymond Hettinger , Doug Mcilroy , Code Review Stack Exchange , King James Bible , Gophers Slack , Rosetta Code , அன்டன் ஏற்த்தல் , ஜான் பென்ட்லி , ஆண்ட்ரூ மகத்தான , மைக் ஹெர்டெல் , டொனால்ட் ந்யூத் , ரேமஂட் ஹெட்டிங்கர் , டக் அம்கில்‌ராய் , குறியீடு விமர்சனம் அடுக்கு பரிமாற்றம் , கிங் ஜேம்ஸ் திருவிவிலியம் , கோஃபர்ஸ் மந்தமான , ரொசெட்டா குறியீடு ,

© 2025 Vimarsana