4 ms·
> C is not that fast. One of the major problems is that it's close to hardware. These days the most important factor to performance, in almost all programs, is
by Peaker 12y ago
> C is not that fast. One of the major problems is that it's close to hardware.
These days the most important factor to performance, in almost all programs, is memory accesses.
Writing cache-friendly code is made relatively easy by C. You control the placement of your data into aligned cache lines. You control the order in which the cache lines are accessed.
The cost of the computational instructions is usually swallowed by the memory misses.
C's common ABI (for x86/64) now passes up to 6 parameters via registers, and doesn't unnecessarily spill to the stack. Additionally, link-time optimizations now allow cross-compilation-unit inlining which can optimize away the ABI costs.