Hacker News new | ask | show | jobs
by arm64future 2247 days ago
>The saying that "processors are optimizing for C" is totally correct.

I thought that the latest consensus on HN was that C is nowhere closer to the hardware.

3 comments

C is close to the interface the hardware presents you – that is, the instruction set – but far from what the hardware actually does.

Caching, out-of-order execution, branch prediction, speculation... all of those things are just as opaque to assembly as they are to C.

> C is close to the interface the hardware presents you – that is, the instruction set – but far from what the hardware actually does.

C isn't even close to that anymore, now that so many processors have SIMD ISAs which C can't usefully model.

Two things are both true.

1. Processors no longer look all that much like C's idea of what a processor is.

2. Processors are optimized to be able to execute C code very well. But an optimizing compiler can make it much better.

There's a fair amount of magic in compilers to make this work.

Any good optimizing compiler is able to achieve this, there is nothing special about C in it.