4 ms·
Higher level languages which rely more on "zero cost abstractions" are much further removed from CPU and memory. Higher level languages are much further remove
by SubjectToChange 6y ago
Higher level languages which rely more on "zero cost abstractions" are much further removed from CPU and memory.
Higher level languages are much further removed from C's model of the CPU and memory. And despite that "distance" there is virtually no difference between C's and C++'s (and often Rust's) performance. And at the end of the day, it doesn't matter how low level your language is if it isn't getting you any performance uplift.
Sure if you dive down into memory-model and CPU-internal details like micro-ops and pipelining then this model quickly falls apart, but on the surface, the "C abstract machine" still maps pretty well to what's happening under the hood.
A core part of the "C abstract machine" is sequential execution. Instruction-level parallelism is par for the course in modern processors, many of which have hundreds of instructions executing at any given time. So C hasn't been reflective of typical desktop/server CPUs for the last 30 years at least.
Hardware vendors spend a lot of money to make C code execute quickly, but we're now seeing the absolute limits of that.
- flohofwoe 6y ago> And despite that "distance" there is virtually no difference between C's and C++'s (and often Rust's) performance. I'm not seeing that in real-world projects though, and it's not only about performance. These are just two random examples from my own experience of where high-level language features get in the way (I guess the TL;DR is: yes, it's possible to write high-performance software in high-level languages, but it's often more effort, and may require to write unreadble and "non-idiomatic" code, because you need to "appease" the compiler much more than in a lower level language): https://floooh.github.io/2018/05/01/cpp-to-c-size-reduction.html https://floooh.github.io/2018/05/01/cpp-to-c-size-reduction.... https://floooh.github.io/2016/01/14/metal-arc.html https://floooh.github.io/2016/01/14/metal-arc.html Also let's not forget about build times.
- verall 6y agoThis is silly. ILP doesn't matter because the HW has kept the same basic ISA with the same memory guarantees since forever. A lot of stuff goes on under the hood to make C code execute quickly (also to make Java code execute quickly, etc). Hundreds of in-flight instructions does not matter when they all commit in order.