Since compiler is basically a program that converts source code to machine code ,how does this compiler program get compiled? I read somewhere about compiler program being able to compile itself but isn't it a normal program, it should also need a separate program that compiles it.
Asked
Active
Viewed 57 times
0
-
1Check this [Quora post](https://www.quora.com/How-is-a-compiler-program-compiled). – itsmysterybox Sep 28 '18 at 16:21
-
The compiler _is_ a program, though. Why _wouldn't_ it be able to compile itself? – jhpratt Sep 28 '18 at 17:28
1 Answers
0
The short general answer as your question is very broad: There are multiple approaches to this but it rests heavily on your goals;
- The compiler compiles itself. This is called self hosted and can be achieved incrementally where each successive version are able to parse/compile additional language features and capabilities that you add. Or,
- Your language source is compiled by another language (e.g. Python, C/C++, etc.) then, as you add features to your language, you support those extensions to your source and then update code you've build in said other language(s). This may be temporary (a.k.a. bootstrapping) and you may revert to option 1 once the produced compiler is robust enough.

Frank C.
- 7,758
- 4
- 35
- 45
-
Did not see the reference to 'already answered' but mine and it are generally aligned. – Frank C. Sep 28 '18 at 20:39