Possible Duplicates:
implementing a compiler in “itself”
Bootstrapping a language
How can you write a compiler in the same language as the language you're writing that compiler for? Isn't that sort of recursive?
Edit: This may be deleted, but otherwise... :
How to bootstrap:
Why to bootstrap:
If the compiler is written in the same language as the one it's compiling, the compiler is called self-hosting. If a language is new, then no compiler exists for it already, which means that its first compiler cannot be self-hosting (otherwise, how would that first compiler be compiled?).
Show activity on this post. A compiler could probably be written in any language. In its most basic form, a compiler merely converts code from one language to another.
compiler, computer software that translates (compiles) source code written in a high-level language (e.g., C++) into a set of machine-language instructions that can be understood by a digital computer's CPU. Compilers are very large programs, with error-checking and other abilities.
Yes it's called Bootstrapping. In computer science, bootstrapping is the process of writing a compiler (or assembler) in the target programming language which it is intended to compile. Applying this technique leads to a self-hosting compiler.
Generally the first version of the compiler is written in a different language, and then each subsequent version is written in that language and compiled with the older version. Once you've compiled version x
with version x-1
, you can use the newly built version x
to recompile itself, taking advantage of any new optimizations that version introduces; GCC does its releases that way
It is. You usually need a bootstrap version of the language either compiled or interpreted from another language.
And to bend your mind a little more, years ago I read the history of a Pascal compiler written as a grad student project. It written in Pascal and compiled with the system's built-in Pascal compiler. Eventually, it was good enough to replace the system's built-in Pascal compiler. Unfortunately, they found a bug in code generation, but the fix for the code generator triggered the bug in the compiler, generating a bad compiler. To fix it required hand-patching the binaries from the installed compiler to then apply the patch to the source to replace itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With