Hacker News new | ask | show | jobs
by swaminarayan 96 days ago
If a working compiler can be written in ~1000 lines, why are production compilers like GCC or LLVM millions of lines?
2 comments

Sparkie is correct, and an actually fully working C compiler in GDSL would probably be 12,000 lines or so total, possibly much more. The point in showing this is that so much of the size of these compilers just comes from managing seams, as I discuss in the essays, and by preserving information through the compiler they shrink dramatically. I would encourage you to compare the implementation of GDSL-C's identifiers to GCC, for a good example of how information availability allows me to link and disambiguate in just 80 lines what GCC takes upwards of a thousand spread across many files to do.
They have dozens of passes for semantic analysis and optimization, often configurable via flags, and they target dozens of different architectures.