Compiler bootstrapping means that the a compiler is coded by it’s own language.
For example, a C compiler may write in C.
??????????????????
This is an Chicken-And-Egg question right???
Where is the first version of the language’s complier from? More exactly, which language implemented first Compiler?
No question, it is written in Machine Code.
After that, we can use a coding language to program the computers. After we got the first compiler of a language, for example, first version of C compiler, we will be able to compile C code, and we can write another C compiler using C, and write a better C compiler base on the compiler we have.
For example:
I have a compiler call mcc, all c code compiler by mcc is 100% faster than gcc. How can I make it work?
First, I need to compile my mcc source code using gcc, so I have mcc 1.0.
All code that compiled by mcc is faster than gcc. So C programs 100 faster!
Is that end? Using mcc to compile code is still slow be cause mcc 1.0 is compiled by gcc. we know that C code that compiled by mcc runs faster, so what if I compiler mcc source code again using mcc1.0?
Yes! mcc 2.0(by mcc 1.0) runs faster 100% than mcc 1.0(by gcc)!
This is compiler bootstrapping.
Nowadays, we have so many great coding languages so seems like there is no reason to implement a compiler using it’s own language?
Well there are many reasons to do that.
When a new language is innovated, people need to validate that the language is easy to use.
Bootstrapping is a validation. Also, Bootstrapping helps the innovator to improve their languages to make it better.
But this does not means that the all common compiler are bootstrapped.
For example: Python and Java.
Python is a bootstrapped language, there is a Python implementation called PyPy. But most of people are using CPython(Implemented by C). The reason is efficiency. Also, Java Virtual Machine also has a Java implemented version, but it is barely used.
However, bootstrapping is still necessary to a language because it is able to validate the language and helps the language to be improved!