4 ms·
I'm always a bit hazy on why people bootstrap languages by writing compilers. I've always imagined it would be easier to write an AST-walking interpreter, write
by rpearl 15y ago
I'm always a bit hazy on why people bootstrap languages by writing compilers. I've always imagined it would be easier to write an AST-walking interpreter, write the compiler in the source language, and then interpret the compiler taking its source as input, to produce the first binary.
I guess I've never actually bootstrapped a compiler, but I've always found the interpreters I've written to be easier to reason about than the compilers I've written.
- nradov 15y agoHardware limitations on the CDC 6000 may have made an interpreter impractical.
- pjmlp 15y agoBootstrapping a compiler is a good way to test how the language feels when writing a big project like a compiler. It also helps to find errors in the language/implementation.
- rpearl 15y agoIn my proposed way to bootstrap a compiler, you still write the compiler in the language you wish to compile. You also write an interpreter, rather than another compiler for the same source language, written in some other language for which a compiler already exists. This means that the amount of code you are writing to get the language up and running is smaller, since interpreters are easier to write than a whole second compiler. So what you say is true--it is a good way to see how the language feels--but not relevant to the facet of language development I was musing about.