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
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
What’s Next for Teal, the typed dialect of Lua - FOSDEM 2021.
This is my talk about the latest updates on the Teal programming language,...
New
Everyone outside of tech has heard of JavaScript, Java, Python, Ruby and even .Net, but few if any have heard of F#. However, F# may be o...
New
Have you ever wanted to write a structurally typed function in Rust? Do you spend a lot of time and effort getting your Rust struct s jus...
New
We take a deeper dive with Nathan Long into IOLists in Elixir. We cover what they are, how they work, the power they have when concatenat...
New
Erlang is famous for its introspecting powers. You can get a lot of information about the processes running in your nodes without any ext...
New
Charles Max Wood takes the lead this week. He and Adi Iyengar discuss what Top End Devs are and what people should be doing to become Top...
New
Another week, another oldies-but-goldies post…
This one about Test Driven Development.
New
Ruby’s Struct is one of several powerful core classes which is often overlooked and under utilized compared to the more popular Hash clas...
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
Other popular topics
A thread that every forum needs!
Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
New
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
Think Again 50% Off Sale »
The theme of this sale is new perspectives on familiar topics.
Enter coupon code ThinkAgain2021 at checkout t...
New
Saw this on TikTok of all places! :lol:
Anyone heard of them before?
Lite:
New
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New
This is cool!
DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON
We just witnessed something incredible: the largest open-s...
New
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
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
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /emacs
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /crystal
- /c-plus-plus
- /tailwind
- /react
- /gleam
- /ocaml
- /flutter
- /elm
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /zig
- /deepseek
- /php
- /scala
- /react-native
- /textmate
- /lisp
- /sublime-text
- /debian
- /nixos
- /agda
- /django
- /kubuntu
- /arch-linux
- /deno
- /nodejs
- /revery
- /ubuntu
- /manjaro
- /spring
- /lua
- /diversity
- /julia
- /markdown
- /slackware








