This is mostly only true for modern optimising C compilers. If you take a simple C compiler from the 90's, or disable optimisations in a modern compiler, there's a near 1:1 relationship between the C code and compiler output.
Unless you’ve written a modern, optimizing C/C++ compiler, you have absolutely no idea what kind of machine code a complex program is going to spit out. It’s not 1972 anymore, and C code is no longer particularly close to the metal. It hasn’t been for some time.
Yesteryear's C compilers weren't great, optimization-wise. But anything remotely modern would just brute force its way through a DOS-era program, well optimized or not.
Well we disagree vehemently: writing clean C code that compiles with any ANSI C compiler is pretty damn easy. Take BIND for example, a non-trivial piece of software which compiles with any compiler.
Does compiling to C-- have any benefits compared to compiling equivalent C code (maybe a subset of C)? My guess would be modern C compilers, powered by decades of R&D and programming, would be able to optimize just as well and possibly better.
EDIT: One advantage that comes to my mind is that compiling to C-- will give slightly more power to deal with stack. E.g. implementing exceptions, continuations etc would be simpler. This is possible in C using inline assembly.
Can you really map gcc output to your C code ? With all the optimizations (CF, CSE, RA, ...) the assembly code can vary dramatically (from what I recall from compilation classes at least)
Their comment makes sense if you interpret "the C compiler" to mean "mainstream C compilers that 99% people use in production" or even just "gcc and clang".
We're talking about concrete things in the real world here, not philosophizing about the language spec.
Also many that praise C's performace, tend to forget that once upon a time, hobby Z80, 6052, 80x86, 68000 programmers in home micros could write better code than C compilers were able to generate.
So there are a few decades of engineering time spent improving code generation of C compilers.
reply