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

Recommended Answers

All 3 Replies

>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.

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. >.<

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.