CommunityNews
Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust
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…
Language Simple Optimized Notes grep0.04 0.04 grepbaseline; optimized setsLC_ALL=Cwc -w0.29 0.20 wcbaseline; optimized setsLC_ALL=CZig 0.54 by ifreund and matu3ba Nim 0.76 0.58 by csterritt and euantorano C 0.97 0.23 Go 1.14 0.39 Crystal 1.29 by Andrea Manzini PHP 1.36 by Max Semenik Rust 1.43 0.38 by Andrew Gallant C# 1.51 0.82 by J Taylor, Y Ostapenko, O Turan OCaml 1.72 by Nate Dobbins and Pavlo Khrystenko C++ 1.73 0.42 optimized by Jussi Pakkanen Perl 1.81 by Charles Randall F# 1.82 1.59 by Yuriy Ostapenko Kotlin 1.86 by Kazik Pogoda Python 2.07 1.30 Lua 2.50 1.97 by themadsens; runs under luajit JavaScript 2.52 1.90 by Dani Biro and Flo Hinze Ruby 3.13 2.43 by Bill Mill AWK 3.55 1.13 optimized uses mawkD 4.16 1.01 by Ross Lonstein Swift 4.23 by Daniel Muellenborn Forth 4.26 1.46 Shell 14.60 1.85 optimized does LC_ALL=C sort -S 2G
This thread was posted by one of our members via one of our news source trackers.
Most Liked
dimitarvp
Yeah, right, as if. They just use bridges to C libraries underneath.
It’s tempting to think your favourite language is fast. But very often it’s just the stdlib shelling out to native implementations. Erlang does it too.
2
Exadra37
Thanks for the post 
It’s missing Elixir… just saying 
1
dimitarvp
PHP faster than Rust and C++?!
Nice joke. 

1
Popular Backend topics
New
When I need to configure something in a complicated way, I find myself reviewing the embedded language that provided the server to create...
New
Just wrote a short post, more a memo to myself, but maybe someone find it useful :stuck_out_tongue:
https://dwarfte.ch/2021/02/03/giving...
New
Idioms for the D Programming Language
This thread was posted by one of our members via one of our news source trackers.
New
One of my favourite programming languages in the last few years has been Crystal. While the language has not yet reached its 1.0 version,...
New
Django 3.2 is just around the corner and it’s packed with new features. Django versions are usually not that exciting (it’s a good thing!...
New
In episode 78 of Thinking Elixir, we talk with Chase Granberry about Logflare. We learn why Chase started the company, what Logflare does...
New
Does the world need another How to create a blog article?
Maybe not.
But then again, creating something out of nothing is what we love....
New
In a 2 day spike, I created my own Elixir-based AI Personal Fitness Trainer! The surprising part for me was how useful and helpful I foun...
New
Episode 244 of Thinking Elixir. News includes the release of Elixir 1.18.2 with various enhancements and bug fixes, a new experimental SQ...
New
Other popular topics
If it’s a mechanical keyboard, which switches do you have?
Would you recommend it? Why?
What will your next keyboard be?
Pics always w...
New
I’ve been really enjoying obsidian.md:
It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
New
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl:
The Ser...
New
Do the test and post your score :nerd_face:
:keyboard:
If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
Author Spotlight
Dmitry Zinoviev
@aqsaqal
Today we’re putting our spotlight on Dmitry Zinoviev, author of Data Science Essentials in ...
New
New
Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New
Latest in C++
Latest in Go
Latest in Python
Latest in Rust
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /rails
- /js
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /emacs
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /opensuse
- /html
- /centos
- /php
- /zig
- /deepseek
- /scala
- /textmate
- /lisp
- /sublime-text
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /deno
- /ubuntu
- /spring
- /nodejs
- /manjaro
- /diversity
- /lua
- /julia
- /slackware
- /c






