Thursday, July 30, 2009

Why we write a C++ compiler in C.?

Compilers are programs that take a source file and turn it into machine code. As such, they take a higher level language and create a lower-level program.


In the beginning, all that existed was machine language. Then, opcodes were writen as assembly code. These were translated into machine language with an assembler. The first compilers were written in assembler, and then we had a way to write programs in higher level languages such as C. It would be much more difficult to write the compiler in assembler (though portions of it may have been done so). So, we use a high level language to create another high level language.

Why we write a C++ compiler in C.?
as the name indicates that c++ is a successor of c. do u learn exactly to write essays in new language without learning alphabets? for java it is both compiler %26amp; interpreter.as the interprter debugs ur source in line by line.it is not incase of c or c++.c++ is a semi object oriented.its compiler may written in top-down or bottom-up manner for better performance.
Reply:Not only C++, almost all compilers are written in assembly level language and C. This is because C language supports some commands of assembly level language.
Reply:Let me ask you this - what other language do you suggest we write them in?





It's going to be C or asm, and personally, I think C is a lot friendly, don't you?!





Rawlyn.
Reply:Because C is a good low level language that is good for such a task. Writing a whole compiler in assembly would be tedious. Writing one with Visual Basic, Java, COBOL, Fortran, C#, etc. in that fashion would be futile, who knows if it would even be possible. And if you have a C++ compiler good enough to build another C++ compiler, why not use the original compiler and bypass the whole hair pulling thing.


No comments:

Post a Comment