7

I've 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".

Felipe
  • 11,557
  • 7
  • 56
  • 103

5 Answers5

12

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!

President James K. Polk
  • 40,516
  • 21
  • 95
  • 125
Costis Aivalis
  • 13,680
  • 3
  • 46
  • 47
  • 2
    It is true. At that time, computers have very limited memory. Nobody believes that a high-level language can compile to a small enough footprint to write large complex programs that fit in memory. C, however, is designed to map almost one-to-one to the PDP assembly language instructions, make the compiled code extremely compact. And, as we say, the rest is history. +1 on this bit of history. – Stephen Chung Mar 13 '11 at 14:26
9

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.

Codo
  • 75,595
  • 17
  • 168
  • 206
  • +1 for not saying 'self hosting' and giving a link. – Tim Post Mar 13 '11 at 14:02
  • 2
    Exactly. How was it possible? – Felipe Mar 13 '11 at 14:03
  • @Felipe: If the question about how to self-host/bootstrap, this questions is a dupe of e.g. http://stackoverflow.com/questions/193560/implementing-a-compiler-in-itself. –  Mar 13 '11 at 14:06
  • @Felipe: nowadays the simplest way is to cross-compile the compiler for the target architecture from a machine for which the compiler already exists. Other methods are illustrated [here](http://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29). – Matteo Italia Mar 13 '11 at 14:08
  • @Felipe: No, we'll just close it as duplicate. Every dupe makes it more likely that people finds the answer before asking again (if they search at all - a debatable assumption) –  Mar 13 '11 at 14:11
  • @delnan Who's **we** in _we'll close it as duplicate_? – Felipe Mar 13 '11 at 14:14
  • 1
    @Felipe Almeida: As your reputation goes up you get more privileges, one of those being the ability to close questions. Many SO users have this level of reputation and will see this and add their vote to close. Once the vote-to-close total reaches 5 the question is closed. – President James K. Polk Mar 13 '11 at 14:21
  • @GregS Thanks for the info. Sorry for my ignorance. – Felipe Mar 13 '11 at 14:23
1

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.

Stephen Chung
  • 14,497
  • 1
  • 35
  • 48
  • I'm no Lisp user, but of course you can write a compiler in it. It has an unusual syntax, but that doesn't make it less powerful. And the way Lisp treats code and data as closely related might make it even easier to write a Lisp compiler in Lisp. – CodesInChaos Mar 13 '11 at 15:54
0

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.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
0

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).

Clifford
  • 88,407
  • 13
  • 85
  • 165