I am sure that you remember this post about language comparison. Now that I enabled AI I made Claude update, rework, and rerun the test with new libraries, new dockers, everything updated.

In short: the idea is to compare some of the most used languages at the moment on the same task: do an insertion sort. That is a quite slow sort alghoritm that brings a lot of unnecessary computational complexity. I run it on a single thread and on a farm of 200 threads.

I want to be totally clear: I let AI do everything, and the concern is that it may have run those tests in parallel, using therefore the same CPU for the parallel tasks. This would make the result a bit different because, when all processes were computing, the languages were slower, but when some of them have finished the processor power would have been distributed among the others.

The following is the table with all results:

LanguageResponse timeSingle-thread sort200-worker farm total× Rust
Rust22.93 ms21.45 ms924.49 ms1.0×
Go56.29 ms53.38 ms2,087.95 ms2.3×
Java334.22 ms177.90 ms7,787.15 ms8.4×
Node.js125.19 ms111.99 ms117,934.50 ms127.6×
Python4,293.80 ms4,279.82 ms431,648.15 ms466.9×

To visualise better, I paste here an interesting image

I loved the comment that Claude left.

Node’s concurrency model is the surprise. Node’s single-threaded sort (112 ms) beats Java’s (178 ms) — but hand 200 concurrent sorts to each, and Node finishes in 117.9 s while Java finishes in 7.8 s. Each worker_threads worker spins up its own V8 isolate; that per-worker startup cost dominates once 200 of them compete for 8 cores. Java’s virtual threads (Project Loom) absorb the same 200 tasks far more cheaply. Python remains the extreme outlier for the same reason the 2022 post found: the GIL forces process-based “parallelism,” and cold-starting 200 interpreters costs far more than the sort itself. Rust and Go, using real OS threads and goroutines respectively, scale close to linearly.

I think this result is not at all surprising, especially because the comparison Java – Node was already like that in the past. I love anyway to look at how Go is similar to Rust, even if it is much more readable.
Stay tuned!

Share