Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,480 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,722 people online right now. Registration is fast and FREE... Join Now!




Compiler compiling itself

 
Reply to this topicStart new topic

Compiler compiling itself

WXY
4 Feb, 2008 - 06:54 PM
Post #1

D.I.C Head
Group Icon

Joined: 2 Jan, 2008
Posts: 85


Dream Kudos: 50
My Contributions
This is just out of dumb curiosity

Let's say that a talented programmer with too much spare time on his hands has decided to and now successfully written a C++ compiler that implements all the C++ standards. In addition he also implements a balanced speed & size optimization algorithm which cannot be turned off.

Now this programmer compiles the compiler with a unnamed compiler thus producing an initial product. What if this programmer would repetitively feed the compiler's source code into the derived compilers like the following:
source code -> unnamed compiler = compiler 1
source code -> compiler 1 = compiler 2
source code -> compiler 2 = compiler 3
... so on

Would the machine code being generated converge or diverge? And would the result be any different if we've built the initial product with a different compiler?

This post has been edited by WXY: 4 Feb, 2008 - 06:54 PM
User is offlineProfile CardPM
+Quote Post

Tom9729
RE: Compiler Compiling Itself
4 Feb, 2008 - 07:15 PM
Post #2

Debian guru
Group Icon

Joined: 30 Dec, 2007
Posts: 1,459



Thanked: 10 times
Dream Kudos: 325
My Contributions
I don't think the compiler that compiled the source code for a compiler would have any effect on the code generated by the new compiler.

I think the machine code for compiler 1 would be "unique", but the machine code for 2, 3, ... would be the same.

Think: does your code do different things depending on the compiler you used? Each compiler has it's little quirks, but a Tic Tac Toe game compiled in GCC is still a Tic Tac Toe game if it's compiled in Visual Studio.
User is offlineProfile CardPM
+Quote Post

Nayana
RE: Compiler Compiling Itself
4 Feb, 2008 - 07:43 PM
Post #3

DIC Hawk - 나야나 नयन:
Group Icon

Joined: 14 Nov, 2007
Posts: 824



Thanked: 5 times
Dream Kudos: 175
My Contributions
No it's not going to get better, because the compiler will always be using the same algorithms to compile the same source code.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:46PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month