Programming language speed comparison using Leibniz formula for π

C++ crowned speed king, Rust surges, and the comments go feral

TLDR: A pi-calculation benchmark crowned C++ fastest while Rust improved dramatically and C# sped up with parallel tricks, igniting debate. Commenters questioned C’s slower results, blamed printing and startup overhead, and argued the test says more about setup than the languages—making methodology the real battleground.

A simple pi test just blew up into a full-blown speed crown brawl. Using the old-school Leibniz recipe to approximate π, a community benchmark lined up languages—and the comments lit up. One user planted a flag with "C++ unsurpassable king", while others gasped at a chart jump from ~200ms to ~900ms, turning the thread into a timing gossip mill. Rust fans rolled in with receipts: 1.94.0 reportedly slashed times from 630ms to 230ms, cue the “upgrade or perish” memes. And the sleeper hit? *“Zig very fast!**” The asterisk even became a running joke.

Then came the twist: SIMD (a computer trick that does many things at once). C# gets a superhero boost (990→225ms), but C++... apparently gets slower with SIMD. The collective reaction: “SIMD giveth, SIMD taketh away.” Cue eyebrow emojis. Meanwhile, why is C slower than C++? sparked a mini war of theories.

Methodology got roasted. One commenter argued the test should ditch file reads and console printing—just pure math. Another noted Clojure wasn’t Ahead-Of-Time compiled (AOT), so the timer includes startup and compilation; do that right and it’s “like Java.” Others squinted at a mysterious Go-to-Racket speed clump. Verdict: the real fight isn’t π—it’s how you measure it. See the repo for the receipts.

Key Points

  • The article benchmarks programming languages on a single task: computing π using the Leibniz formula.
  • A uniform algorithm is implemented across languages to enable fair performance comparisons.
  • The focus is on runtime performance for the identical numerical workload.
  • The methodology aims to reduce variability by keeping the computational approach consistent.
  • Comparative results are presented per language for the chosen π computation task.

Hottest takes

"C++ unsurpassable king." — forgotpwd16
"Is there a explanation for why C is slower than C++?" — theanonymousone
"the comparisons could be better if the file I/O and console printing were removed" — nmaludy
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.