Name: Anonymous 2007-10-08 20:02
One of the students bought this question up in a tutorial and this anon thought it would be interesting if it was discussed with his other aliases on 4ch.
The question this anon was approached with was:
If one day a keen programmer (with too much free time) decided to write a new C compiler in C, and succeeded.
Assuming that the following holds:
-It is actually possible to write a C compiler in C for the architecture & build environment
-The series of operations that we are about to conduct are all isolated on the original build environment and CPU architecture
-All of the C language aspects employed by the source code of the new compiler are implemented properly in the source code.
-The code is magically debugged and will fully function to it's designed functionality contracts.
-The new compiler has optimization algorithms that will fully preserve functionality of the inputed code.
-No inappropriate usage of the C language was employed in the source code (such as language hacks)
Now the programmer compiles the written source code in an industry standard C compiler, producing a derived C compiler. If the source code is then repetitively fed into the derived compilers, what would happen?
1) The machine code size will converge to a resultant product that will be in full equilibrium, and will be much more optimized than the predecessor compilers (excluding the original product that is not manufactured by this source code)
2) The machine code size will diverge however maintains functionality, efficiency however may vary.
3) The machine code size will diverge, and functionality will not be maintained thus eventually leading to an error and failing to create additional derived compilers.
4) Something else? Explain.
My answer was 2. What do you think?
The question this anon was approached with was:
If one day a keen programmer (with too much free time) decided to write a new C compiler in C, and succeeded.
Assuming that the following holds:
-It is actually possible to write a C compiler in C for the architecture & build environment
-The series of operations that we are about to conduct are all isolated on the original build environment and CPU architecture
-All of the C language aspects employed by the source code of the new compiler are implemented properly in the source code.
-The code is magically debugged and will fully function to it's designed functionality contracts.
-The new compiler has optimization algorithms that will fully preserve functionality of the inputed code.
-No inappropriate usage of the C language was employed in the source code (such as language hacks)
Now the programmer compiles the written source code in an industry standard C compiler, producing a derived C compiler. If the source code is then repetitively fed into the derived compilers, what would happen?
1) The machine code size will converge to a resultant product that will be in full equilibrium, and will be much more optimized than the predecessor compilers (excluding the original product that is not manufactured by this source code)
2) The machine code size will diverge however maintains functionality, efficiency however may vary.
3) The machine code size will diverge, and functionality will not be maintained thus eventually leading to an error and failing to create additional derived compilers.
4) Something else? Explain.
My answer was 2. What do you think?