0

I've heard that compilers are built by compiling themselves? How can they possibly do this, how would you get it to compile itself?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Narue
0

>How can they possibly do this, how would you get it to compile itself?

  1. Write an initial compiler for your new language in an existing language (ex. the first Pascal compiler was written in Fortran).
  2. Write a bootstrapping compiler for your new langauge with that initial compiler.
  3. Your new language now compiles itself with the bootstrapping compiler.

Edited by Narue: n/a

0

Thanks for the reply, it was helpful. But what I still don't understand is how bootstrap compilers work? Or how anything in a computer that is a bootstrap works, my mind has a hard time when it's thinking about things in a computer that load themselves. >.<

0

A bootstrapping compiler is a compiler, nothing more, nothing less. It just happens to be written in the same language it compiles.

>my mind has a hard time when it's thinking about things in a computer that load themselves
Then your problem is understanding what a compiler is. It's completely irrelevant what language a compiler is written in unless you're trying to advertise your language[1]. All a compiler does is convert one language into another. It could be Java into bytecode, or C++ into object code, or C into assembly, or any combination you'd care to imagine.

[1] A bootstrapping compiler is a non-trivial test of a language, which is used in making claims about the language's maturity.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.