4 ms·
Being an ignorant fool with an uninformed opinion, I would like to see a C compiler that is evaluated and critiqued not only based on the warnings and errors it
by aplorbust 11y ago
Being an ignorant fool with an uninformed opinion, I would like to see a C compiler that is evaluated and critiqued not only based on the warnings and errors it generates but, more importantly, on the assembly it generates.
Namely, how compact and readable is the generated asm? When we read the asm, can we easily follow what the compiler has done and _why_?
As an ignorant fool, in my mind C is still a shorthand for writing assembly, to save old programmers from continuing to be or new programmers from becoming "assembly language programmers". Obviously many years have passed and "C" has become an institution and means much more to so many people. Aopologies to those people. I am just a fool.
I see the _theoretical_ "C compiler" as nothing more than a code generator, spitting out assembly. Obviously the _practical_ C compiler is very different. Base on the way it's used, it seems inextricably linked with a "preprocessor" (glorified sed).
It is said that asm has a "one to one" relationship with machine code. Theoretically, we can look at asm and determine its machine code equivalent without any "clever" algorithms.
My humble, ignorant fool's opinion is that it would be better if C had a closer relationship to the asm the "C compiler" generates.
Maybe not "one to one" but at least "predictable, boring".
Forgive me for having opinions about overly complex things few people can comprehend (e.g., a "modern C compiler"). I am just an ignorant fool who likes code generators. Especially ones that output assembly.
- sanxiyn 11y agoI agree it would be an interesting exercise to write a compiler optimized for assembly readability. But I don't think there is enough demand for such a thing so that it will get written. It also would be interesting if those who think there is enough demand start a crowdfunding campaign to prove that there is enough demand.
- pjtr 11y agoMost C compilers have a flag to turn this mode on. It's usually called -O0 and is actually the default.
- nwmcsween 11y agoC doesn't turn into some magical obtuse assembly with optimizations enabled, a loop will still be visible in some way but might vectorized, unrolled, eliminated or even merged but you can still map it to the source. It's interesting to see what a compiler can do: ICC does some really fancy stuff such as eliminating whole chunks of code that are meant to help most compilers vectorize.
- aplorbust 11y ago"_compact_ and readable" For me, the former compliments the later. The less code I have to read, the better.