2 ms·
C++ was never at any stage a preprocessor. It was, instead, the first of what became many, many compilers that generated C from its AST as the target assembly
by ncmncm 5y ago
C++ was never at any stage a preprocessor.
It was, instead, the first of what became many, many compilers that generated C from its AST as the target assembly language, relying then on the C compiler's optimizer and machine-code generator.
Nowadays, LLVM IR fills exactly the role C once did, for new languages like Rust and Zig. Zig is just now in the middle of transitioning to its own optimizer and machine-code generator.
Preprocessors were also common at the time, e.g. m4, Ratfor, and Cpp ("C preprocessor", which initially was a separate program), so it is not surprising that Cfront was mistaken for one, back then.
That is not a reason to repeat the falsehood.
You don't get a runaway success for four decades by accident.
- kazinator 5y ago> generated C from its AST as the target assembly language, relying then on the C compiler's optimizer and machine-code generator. That qualifies as a preprocessor to me. You can get the sources to it, as late as 3.0.3 from 1994 here. http://www.softwarepreservation.org/projects/c_plus_plus/index.html http://www.softwarepreservation.org/projects/c_plus_plus/ind...
- ncmncm 5y agoIf "preprocessor" means anything at all, it means a program that alters incoming text according to textual rules, without analyzing language semantics. The C preprocessor operates strictly on text patterns. Likewise Ratfor. Likewise m4. Otherwise every compiler is a preprocessor, and the word is meaningless. Making words meaningless could be a way to make yourself feel important, but it does not advance understanding. Since Cfront, up until LLVM, almost all new-language compilers emitted C code. They were not preprocessors. Compilers that emit LLVM IR are also not preprocessors.
- kazinator 5y agoOf course, something using C as a target language can be a substantial compiler. But not everything that outputs C is in the special category of taking "C with classes" to "C without classes". My root comment is strictly about the initial impetus and proof-of-concept implementation, not ISO C++20. Oh look, here is a quote from Stroustrup's HOPL paper about the history of C++: In October of 1979 I had a pre−processor, called Cpre, that added Simula−like classes to C running and in March of 1980 this pre−processor had been refined to the point where it supported one real project and several experiments. I think, if it's okay for Stroustrup to say "preprocessor" (and even put "pre" in the thing's name), it's okay for me.
- ncmncm 5y agoTerminology has stabilized, since. Cpre parsed and analyzed C-with-classes code, and synthesized C code just like any of the later compilers, and Cfront.