So I’ve already posted this question on Stack Overflow, but I wanted to ask it here as well, since I am not sure if they will simply say it is a duplicate (even though the other answers from other questions don’t answer what I asked in a way that helps me).
[https://stackoverflow.com/questions/78539284/in-bootstrapping-how-is-the-compiler-written-in-the-other-langauge-such-that-it](https://stackoverflow.com/questions/78539284/in-bootstrapping-how-is-the-compiler-written-in-the-other-langauge-such-that-it)
So I was wondering if there were direct examples people could give of how the bootstrap compiler is actually written such that it actually represents the language you want to write in another language, because my head can’t wrap itself around it and most sources are fairly vague and just assume you know how it is done.
Hell, maybe if people try and explain it in a metaphorical way and walk me through how the bootstrap compiler is written to represent language X in language Y, that might help too, since I am not a programmer, but this concept is stressing me out from knowing I don’t understand it.
In: Technology
Computers are designed to process from a few dozen to several hundred “instructions” directly. Something like “load value 10 into register X”. This instruction is represented as numbers in a file; it could be “43 12 10” as decimal numbers. The file would not be text like this but “binary”, or a format the computer can read directly; not particularly friendly for people to write. To make things easier we write a program to take a text version of this, for example “ldx #10” and write out the binary file. This is a tremendous improvement and was done starting in the 1950s. As nice as this is we wanted to do better, to write statements like “num_parts = 10”. A compiler knows how to translate that into the text version of the machine code the we run THAT translator on that file.
So, way back when, someone wrote the first simple compiler in the text version of the machine code, probably for a minimal subset of their language, then used that mini language to implement a compiler for the full language. This process is known as “bootstrapping” a compiler.
Of course now we would just start with an existing language to create the initial version of your target language.
Latest Answers