'What is the language of compilers? Are they written with different languages?
Are compilers in different languages?
Solution 1:[1]
A compiler could probably be written in any language. In its most basic form, a compiler merely converts code from one language to another. In the sense that most people use the term "compiler" today, they are referring to something that takes in source code of some higher level language and converts it to either assembly or some low level intermediate language (CIL).
Solution 2:[2]
Compilers are often written in the language of said compiler. For example, a C compiler is typically written in C.
... which brings up the question "how do you compile it the first time?". To which I've heard two answers: either it is hand compiled (as scary as it sounds), or one cheats and uses an existing compiler for that language.
As @jball has commented, read the Wikipedia article on Bootstrapping for complete details.
Solution 3:[3]
Sometimes yes, sometimes no. It's customary to try and implement the compiler for a new language in that language itself as soon as possible, partially to prove that it can do "heavy lifting".
But of course, you first need a compiler or at least interpreter to run that compiler and have it compile itself - so you first have to implement it in a different language.
And for many specialized languages, writing the compiler in the language itself is not practical because the language is not meant for things like compilers.
Solution 4:[4]
What is the language of anything? gcc for instance is written in C.
There was once a story about a Lisp interpreter that was written in Lisp.
This brings up the following question - if the C compiler is written in C then what compiled the first C compiler? For this, read here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Peter Mortensen |
| Solution 2 | Bob Kaufman |
| Solution 3 | Michael Borgwardt |
| Solution 4 | Peter Mortensen |
