Jump to content
  • Advertisement
Sign in to follow this  
asdqwe

compiler for compiler for compiler

This topic is 3851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've always wondered what compiler produced the VStudio 6/7/8/9 executables or the RHIDE/GCC/CodeBlocks' executables (they had to be compiled somewhere!). Also what compiler put together THAT compiler and so on...

Share this post


Link to post
Share on other sites
Advertisement
Compilers can be used to compile their own source code (pretty sure that's called "self-hosting"). Obviously that isn't possible for a new language, in which case the compiler is first written in another language.

In the absence of any higher level languages, the compiler would need to be manually entered machine code I guess.

Share this post


Link to post
Share on other sites
It's been building since the dawn of computing. At first there was nothing but switches (or worse, hard-wired programs). Then, someone along the way made an assembler which took human-readable instruction mnemonics and produced machine code. That program would have been re-written in the assembly language itself to make it easier to change.

To implement a high-level language in itself, you'd first have to implement a small subset of that language in assembly code (or some other available language). Then do as was done before and re-write the language in the subset of itself. At this point it can now compile itself. Write new features for the language then go back and use those features to make the compiler better. The cycle continues until the language is "done" or it's used to bootstrap yet another self-hosting language.

Share this post


Link to post
Share on other sites
Quote:
Original post by pala_
Compilers can be used to compile their own source code (pretty sure that's called "self-hosting").

Correct.

@asdqwe:
The case of PyPy might prove instructive - and demonstrates that self-hosting is not limited to any particular type of language or execution model. The Mono C# compiler is also self-hosting, as are the Mono Visual Basic.NET and Oberon compilers.

As you can see, self-hosting implementation is quite common among programming languages, and is sometimes considered a significant benchmark of the language's adaptability to both expressiveness and performance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!