4 ms·
Maybe Intel C++ as well? But most people who have that book didn't buy it to write a compiler. Isn't C++ ridiculously hard to write a compiler for? While I have
by csl 10y ago
Maybe Intel C++ as well? But most people who have that book didn't buy it to write a compiler. Isn't C++ ridiculously hard to write a compiler for? While I haven't written one, I think it'd be much easier to write one for C — and for that I imagine it would very nearly suffice to have the K&R book.
- WalterBright 10y agoEvery C++ front end I know of has at least 10 man years in it. I'm pretty sure it's the hardest language to implement, by far. (The core language.) Ironically, one of the hardest things about a C compiler is the preprocessor. You'd think a text macro processor would be simple, and it should be simple. There's an amazing amount of subtle complexity in just the handful of pages describing it in the Standard. I and many others implemented a C compiler based on K+R, and I can attest that a lot of rework can be avoided if following a Standard instead (C89 did not exist at the time).
- mafribe 10y agoI'm pretty sure it's the hardest language to implement Harder than languages that require JIT compilers to achieve reasonable performance? Even scalac and ghc are pretty complex beasts in order to Scala and Haskell reasonably speedy.
- Retra 10y agoYou can sink 10 years into just about any software to make it run faster. I wouldn't think that reflects on the inherent difficulty of writing a compiler in the abstract.
- mafribe 10y agoSure, but a simplistic C++ compiler will still produce code of acceptable speed. The same is not true of simplistic compilers for languages like Javascript. Meta-tracing a la PyPy is such a revolution because it enables low-cost creation of reasonably performant tracing JIT compilers.
- wtetzner 10y agoI read the comment as saying C++ is the hardest language to implement, not the hardest language to make fast.
- mafribe 10y agoSpeed and type-inference are the two hard things in compilation in my experience.
- WalterBright 10y agoI've written a Java compiler, and a friend of mine (Steve Russell) wrote the JIT for it (for Symantec). It was the first JITting Java compiler, and took only a few months to complete. Of course, I should have said "front end". Working on the optimizer/codegen is an endless process.
- mafribe 10y agoYes, C++ has a baroque syntax, and I wish lexing/parsing C++ on nobody.