Re: Compiler vs. Translator

Martin Ward <>
30 May 2004 13:19:11 -0400

          From comp.compilers

Related articles
Compiler vs. Translator (Paul Robinson) (2004-05-16)
Re: Compiler vs. Translator (2004-05-24)
Re: Compiler vs. Translator (glen herrmannsfeldt) (2004-05-24)
Re: Compiler vs. Translator (Richard F. Man) (2004-05-24)
Re: Compiler vs. Translator (Martin Ward) (2004-05-30)
Re: Compiler vs. Translator (glen herrmannsfeldt) (2004-05-30)
Re: Compiler vs. Translator (2004-06-06)
Re: Compiler vs. Translator (2004-06-15)
| List of all articles for this month |

From: Martin Ward <>
Newsgroups: comp.compilers
Date: 30 May 2004 13:19:11 -0400
Organization: Compilers Central
References: 04-05-051 04-05-058
Keywords: translator, comment
Posted-Date: 30 May 2004 13:19:11 EDT

On Monday 24 May 2004 5:21 am, wrote:
> There is no real difference between writing a compiler or a language
> translator, actually. If you think about it, they're really the same
> animal. What you'd call a compiler is actually a translator from your
> high-level language into assembly language or straight machine code.

In theory, yes. In practice there is a huge difference. ("The
difference between theory and practice is that in *theory* there is no
difference between theory and practice, but in *practice* there is").

A translator usually has to generate nice, structured, maintainable
code in the target language which makes use of idioms in the target
language where possible. A compiler can generate any code it likes,
however ugly, which is syntactically valid for the target language.

A compiler has to cope with any valid syntax in the source language,
and generate semantically equivalent code in the target language. A
translator usually has a fixed body of code that it is required to
translate, and may have some leeway over rarely used idioms which are
hard to translate automatically (generating a "FIXME" comment with
manual intevention required to complete the task).

A compiler usually has to do optimisation. A translator can rely on
the compiler for the target language to do optimisation: in fact, it
should *not* do optimisations which affect readability of the code.

A compiler is translating from a higher level language to a lower
level language (or to a low level subset of the target language). A
translator is usually translating from a high level language to
another high level language, or from a low level language to a high
level language. For example, translating from assembler language to C
or COBOL (see for

[I agree that they're different, but contrary to what one might hope,
a translator is certainly no easier to write. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.