Get the latest tech news
Counting words in Python, Go, C++, C, Awk, Forth, and Rust (2021)
Performance comparison of counting and sorting word frequencies in various languages (Python, Go, C++, C, AWK, Forth, and Rust)
It’s the kind of thing a programmer might have to write a script for in real life, and it shows whether they understand file I/O, hash tables (maps), and how to use their language’s sort function. It’s not great to have a fixed size table, but adding dynamic resizing is just busy-work, and doesn’t slow down the running time significantly, so I’ve left that as an exercise for the reader. LanguageSimpleOptimizedNotes grep 0.040.04 grep baseline; optimized sets LC_ALL=Cwc -w 0.280.20 wc baseline; optimized sets LC_ALL=C Zig0.550.24by ifreund and matu3ba and ansinghNim0.770.49by csterritt and euantoranoC0.960.23Go1.120.40OCaml1.18by Nate Dobbins and Pavlo KhrystenkoCrystal1.29by Andrea ManziniRust1.380.43by Andrew GallantJava1.401.34by Iulian PlesoianuPHP1.40by Max SemenikC#1.500.82by J Taylor, Y Ostapenko, O TuranC++1.690.27optimized by Jussi P, Adev, Nathan MPerl1.81by Charles RandallKotlin1.81by Kazik PogodaF#1.811.60by Yuriy OstapenkoJavaScript1.881.10by Dani Biro and Flo HinzeD2.050.74by Ross LonsteinPython2.211.33Lua2.502.00by themadsens; runs under luajitRuby3.172.47by Bill MillAWK3.551.13optimized uses mawk Pascal3.67by Osman TuranForth4.221.45Swift4.23by Daniel MuellenbornCommon Lisp4.97by Brad SverclTcl6.82by William RossHaskell12.81by Adrien GlauserShell14.811.83optimized does LC_ALL=C sort -S 2G What can we learn from all this?
Or read this on Hacker News