Bootstrapping (compilers)

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

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

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

  1. Reynolds, John H.. Bootstrapping a self-compiling compiler from machine X to machine Y. Journal of Computing Sciences in Colleges 19 (2) (December 2003). p. 175–181.
  2. Advanced Build Configurations — LLVM 10 documentation. llvm.org.
  3. Installing GCC: Building. GNU Project - Free Software Foundation (FSF).
  4. Tim Hart and Mike Levin. AI Memo 39-The new compiler. Retrieved 2008-05-23.