eli5: In bootstrapping, how is the compiler written in the other langauge such that it can then compile the original language i.e. the bootstrap compiler?

1.02K viewsOtherTechnology

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

17 Answers

Anonymous 0 Comments

So I think basically you need to understand what a programming language is. It’s a code. Like, think about spies. They write messages to each other, in secret code, and they have a little book that tells them what the code is, and they can translate the message. And make it readable.

So, the only language that a computer actually speaks is binary. It has to be 1s and 0s, at the end, or else the computer doesn’t understand.

When you write “code” in a programming “language”. The language is really a specific “code book”. All the words and symbols and syntax represent blocks of 1s and 0s. And the compiler just takes all that, and translates it into the computer language. Makes it actually be 1s and 0s. So it’s like you’re a spy, and the computer is the other spy, and you’re writing a coded message. The compiler is that part where you need a code book to translate the meaning.

So the compiler itself is just a computer program. Everything the computer does is a computer program. The program can be written in any language. It just needs to have access to the specific “code book” that this specific “spy”is using.

You are viewing 1 out of 17 answers, click here to view all answers.