Wikipedia describes a bootstrap compiler to have these properties:

  • An initial core version of the compiler
  • A minimal subset of the language to be used by successive compiler versions

Everything I've read online assumes an initial subset version gets bootstrapped, but isn't it possible to bootstrap a recent compiler version (using the latest released binary)?

Wouldn't this benefit the compiler writer?: being able to dogfood the new features.

While I'm not aware of a language that uses latest version as bootstrap, I'm sure they could exist; I'm just wondering if there are good reasons not to. Thanks!

As a concrete example, the Go programming language docs explain that the default bootstrap compiler is version 1.4. Hence, the latest Go compiler code can't have new features added after 1.4 (ie: type alias), except maybe in tests only.

Update: additional explanation for my question, If a bug needs to be fixed in the core compiler 1.4 after-the-fact, and this bug could affect all later versions, then they need to be compiled again. Depending on how the bootstrap chain happens, might have differing implications. Is there a reason to use one way or the other?:

  • Option A [1 level]: 1.5 compiles with 1.4, 1.6 compiles with 1.4
  • Option B [n levels]: 1.5 compiles with 1.4, 1.6 compiles with 1.5 (that was compiled with 1.4)

(1.4 is the Core version)

  • Roslyn (the c# compiler in c#) makes use of recent features as far as im aware. In general, though, you have to start somewhere. So you implement the bare minimum in the first version, then successively bootstrap higher level features until you have the 1.0 compiler. May 9 '19 at 17:38
  • Thanks @D.BenKnoble, that'd be very interesting if the roslyn compiler uses new features in its code. I think you are saying that there is a bare version that is the smallest subset of features, but you can bootstrap over and over again forming larger sets of language features but then at a certain point you can say stop bootstrapping beyond 1.0 for newer versions.
    – progner
    May 9 '19 at 18:50

Think about why bootstrap compilers exist. Higher level languages that need to create executable code need something to work with to get started. When you are starting from scratch, you have a couple options:

  • Use an unrelated language to create your compiler
  • Generate enough of a compiler to generate the real compiler using your own language to build it

I've seen both approaches used, particularly if we are talking about lanaguages that run on a common runtime platform like the Java Runtime or Common Language Runtime (i.e. dotnet). However, many programming language writers prefer the language they created.

Creating a bootstrap compiler is actually a hard problem. You need enough created so you can have something to work from. Often times, there are multiple levels of bootstrapping required. There are a few reasons why you use older versions of the language:

  • Trying to implement advanced language compiler features in a more primitive bootstrap compiler is really hard.
  • A bootstrap exists just to get you going. The bootstrap compiler can build the real compiler, so why go back and change it?
  • You ain't going to need it (YAGNI). The idea is to build just enough so you can build the full compiler.
  • Once you have the full compiler, you can build anything.
  • Very useful information, thank you! I'm curious what circumstances would call for multiple bootstrapping levels or just 1-level. For example, a change to the core 1.0 version binary would propagate to all the later versions (let's say a total of 3 versions), but how that happens could be 1-level directly for each: 1.0, 1.0 -> 1.1, 1.0 -> 1.2 or multiple levels: 1.0, 1.0->1.1, 1.0->1.1->1.2
    – progner
    May 9 '19 at 18:35
  • That depends on the language and if you are truly bootstrapping from absolutely nothing. Don't think of it necessarily in terms of versions of language capability, think of it in terms of what's necessary to get a compiler from nothing available. The GNU C Compiler (GCC) team had to do just that, and do it in a cross-platform way. The steps required really depend on the language itself. May 9 '19 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.