开发者

What does it mean to say that C was compiled in C? [duplicate]

This question already has answers here: Bootstrapping still requires outside support (11 answers) Closed 8 years ago.

I've开发者_JS百科 seen stuff like this written... C was written in C, or ABAP was written in ABAP..

I've even seen one guy saying that this is one of the criteria to sort languages into true programming languages.

I'd like someone to explain to me what this means.

Thanks in advance.

EDIT:Changed title from: "C was made using C" to "C was compiled using C".


You start with assembly, you make a first version and can always write a new version of a compiler with the previous version.

You do not need a compiler in order to start compiler written in its language. You just need to write an interpreter for a C subset. Then you use this subset in order to enhance it.

At the time C was invented (around 1967) nobody thought it was a sane idea to write a compiler or an Operating System in a high level language, except Brian Kerninghan and Dennis Ritchie. They proved to be right!


It means that the C compiler was written in C.

Initially, that's a problem because how can you write a compiler in C if not compiler exists yet for C.

Update:

If you write a compiler in a differnt language, people ask themselves whether the language is too limited for building a compiler or whether the inventors of the language aren't convinced of their language and preferred another one.

But there are good reasons for writing a compiler in a different language.


Compilers are relatively complicated programs, so it is sometimes assumed that the ability to write something like a compiler is an indication that a computer language has enough power to write complicated programs -- i.e. a "true" programming language.

The compiler doesn't have to be written in the same language as it is compiling. For example, if C is used to write a Pascal compiler, it still fulfills the (somewhat non-scientific) test that C is a true programming language.

Obviously, for there to be a test, there has to be computer languages that are not powerful enough to write a compiler -- or that it may be so convoluted/complicated that it is not even attempted. Some 4GL, certain scripting languages, or specialized language (can you write a compiler in LISP? I dunno...) may fall into this category.

As mentioned, this is by no means a "scientific" test of a language. It originally came about only for marketing. There are some slight benefits though -- having a compiler, the O/S and utilities written in the same language means that you can have a complete programming environment in one single language, vastly simplifying maintenance. Unix and C is a good first example of a "C-only" environment.


It doesn't really mean anything. Statements like that can't really be applied to a language as a whole, merely specific implementations of it. For instance, the code for a C compiler may well be written in C.


I would suggest that the true test for "true language" would be whether it was Turing complete. Interpreted languages are no less true-languages, but you could not write the interpreter in the interpreted language, which may be what your "one guy" is referring to. (Actually you could, but you'd need the original interpreter present to run the new interpreter, several generations later it would be horribly slow and large).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜