Bootstrapping (compilers)
Appearance
Bootstrapping is a computer science method to create a programming language, that is compiled with itself. In most cases, a compiler is written in a language, where the compiler is rewritten for the language that is being compiled.[1]
Most popular programming languages all follow a pattern of bootstrapped compilers. Some include Java, C#, C, Rust, Ruby, Python, and more.
Process
[change | change source]Bootstrapping usually has just a few stages: [2]
- Build & prepare tools, and software to create a bootstrap compiler.[3]
- Stage 1: Create a compiler for your programming language using another language, or whatever tools you have. This will be used to compile your final compilers.
- Stage 2: Use your created compiler to recreate your original compiler. This should be identical to a stage 1 compiler.
- Stage 3: Any newly added features would be added at stage 2, where the language is now only written in itself, and is compiled using a compiler, compiled in the same language.
Early Bootstrapping
[change | change source]In 1962, Tim Hart, and Mike Levin wrote a compiler for LISP, inside of LISP.[4] They improved the compiler until it was capable of compiling itself.
References
[change | change source]- ↑ Reynolds, John H. (December 2003). "Bootstrapping a self-compiling compiler from machine X to machine Y". CCSC: Eastern Conference. Journal of Computing Sciences in Colleges. 19 (2): 175–181.
The idea of a compiler written in the language it compiles stirs up the old 'chicken-or-the-egg' conundrum: Where does the first one come from?
- ↑ "Advanced Build Configurations — LLVM 10 documentation". llvm.org.
- ↑ "Installing GCC: Building". GNU Project - Free Software Foundation (FSF).
- ↑ Tim Hart and Mike Levin. "AI Memo 39-The new compiler" (PDF). Archived from the original (PDF) on 2020-12-13. Retrieved 2008-05-23.