Trust your compiler: Modern C++

Old coding tricks just got called washed as commenters fight over trusting the machine

TLDR: The article says many famous old C++ speed tricks are outdated because modern compilers and processors can often make simple code just as fast. Commenters were split between trusting the tools and treating them like unholy black boxes, with side drama over risky settings and compiler bloat.

A spicy new C++ write-up basically tells programmers to stop worshipping ancient speed hacks and let today’s compiler do the heavy lifting. The article revisits legendary tricks like Quake III’s famous fast inverse square root and argues that on modern chips, the “boring” version can be just as good — or better — because today’s tools are smart enough to recognize patterns and optimize them automatically. Translation for normal humans: that clever shortcut your favorite 1999 game developer used may now be more nostalgia than necessity.

But the real fireworks were in the comments, where the community split into two camps: Team Trust the Compiler and Team Absolutely Not, Are You New Here? One commenter went full conspiracy mode, calling compilers “invisible backdoor injectors,” which is the kind of line that turns a coding thread into reality TV instantly. Another grumbled that the article’s results lean on fast-math, a setting that allows riskier shortcuts and isn’t something many people can safely switch on for an entire project. In other words: yes, your code may go faster, but some readers are screaming, “At what cost?”

Then came the old-school romantics. One person blasted modern compilers as giant, bloated mysteries and wistfully praised the tiny Plan 9 compiler as something “a man could understand,” which is both a technical opinion and a cowboy monologue. Elsewhere, people bickered over whether virtual calls and exceptions are still performance villains, turning the thread into a greatest-hits album of programmer grudges. The mood? Half benchmark battle, half therapy session for people who don’t want to admit the machine might be smarter than them now.

Key Points

  • The article argues that much inherited C++ performance advice was shaped by older hardware and may not apply on modern CPUs and compilers.
  • It states that modern compilers such as Clang and GCC can often optimize straightforward code effectively, sometimes making hand-written tricks unnecessary or harmful.
  • The benchmark environment is explicitly defined: Ubuntu 24.04 LTS, Linux kernel 6.18.1, AMD Ryzen 9 9950X, 128 GB DDR5/3600, and Clang 21.1.1 with `-O3 -ffast-math -mtune=native`.
  • The first examined example is Quake III Arena’s fast inverse square root, which historically improved performance by replacing expensive floating-point operations with bit manipulation and a Newton iteration.
  • The article notes that modern CPUs provide dedicated reciprocal square root instructions on x86 and ARM architectures, and that compiler behavior in the comparison depends on flags such as `-ffast-math`.

Hottest takes

"invisible backdoor injectors" — sylware
"Nobody understands the big compilers any more" — Glandalf
"we can't change the whole program by using -ffast-math" — kzrdude
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.