Eli5: If a compiler is a program that converts your code into binary form for the computer, unless my understanding is incorrect and it isn’t just a program, wouldn’t the compiler also need a compiler to run it since how do you run a program without a compiler?

1.04K views

Eli5: If a compiler is a program that converts your code into binary form for the computer, unless my understanding is incorrect and it isn’t just a program, wouldn’t the compiler also need a compiler to run it since how do you run a program without a compiler?

In: 360

25 Answers

Anonymous 0 Comments

This is the compiler bootstrapping problem. Nowadays the compilers are juste written in another language where a compiler already exist. Once the program have compiled there is no need for a compiler any longer so you can run this program without having the original compiler. This is how you can create an independent compiler. Some procramming languages can also be interpreted, where you need the interpreter to run it. So you can write a compiler, run it in the already existing interpreter, and have it compile itself.

In the old days, when compilers were still quite rare. You could write machine code directly, or partially helped by existing tools. There are several such known projects where a compiler were first compiled to machine code by hand. Once the first hand written copy was down you could use this to compile the code properly.

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