
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 grep
0.04 0.04 grep
baseline; optimized setsLC_ALL=C
wc -w
0.29 0.20 wc
baseline; optimized setsLC_ALL=C
Zig 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 mawk
D 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

Ten years without Elixir.
I never got into Elixir, largely because it looked like Ruby. I was a Rubyist for a good while, spent time and...
New

In a previous post we talked about implementing a simple video chat with WebRTC and Elixir. This update will touch on some of the API cha...
New

Idioms for the D Programming Language
This thread was posted by one of our members via one of our news source trackers.
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

Go is not an easy programming language. It is simple in many ways: the syntax is simple, most of the semantics are simple. But a language...
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

PHP 8.1 is already taking shape quite well, yet there’s one feature I’d love to see added, that’s still being discussed: multi-line short...
New

Too long have we hustled to deploy Clojure websites. Too long have we spun up one server instance per site. Too long have reminisced abou...
New

When DoorDash approached the limits of what our Django-based monolithic codebase could support, we needed to design a new stack that woul...
New
Other popular topics

Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New

My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New

poll
poll
Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New

On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New

“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin
Even when you’re ultimately right about what the future ho...
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

The overengineered Solution to my Pigeon Problem.
TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New

Author Spotlight
Erin Dees
@undees
Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New

Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New

This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
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
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /onivim
- /svelte
- /typescript
- /crystal
- /c-plus-plus
- /kotlin
- /tailwind
- /gleam
- /ocaml
- /react
- /flutter
- /elm
- /vscode
- /ash
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /sublime-text
- /textmate
- /debian
- /nixos
- /lisp
- /agda
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /django
- /spring
- /manjaro
- /diversity
- /nodejs
- /lua
- /c
- /slackware
- /julia
- /neovim