|Compiler vs. Translator email@example.com (Paul Robinson) (2004-05-16)|
|Re: Compiler vs. Translator firstname.lastname@example.org (2004-05-24)|
|Re: Compiler vs. Translator email@example.com (glen herrmannsfeldt) (2004-05-24)|
|Re: Compiler vs. Translator firstname.lastname@example.org (Richard F. Man) (2004-05-24)|
|Re: Compiler vs. Translator Martin.Ward@durham.ac.uk (Martin Ward) (2004-05-30)|
|Re: Compiler vs. Translator email@example.com (glen herrmannsfeldt) (2004-05-30)|
|Re: Compiler vs. Translator firstname.lastname@example.org (2004-06-06)|
|Re: Compiler vs. Translator email@example.com (2004-06-15)|
|From:||Martin Ward <Martin.Ward@durham.ac.uk>|
|Date:||30 May 2004 13:19:11 -0400|
|Posted-Date:||30 May 2004 13:19:11 EDT|
On Monday 24 May 2004 5:21 am, firstname.lastname@example.org 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 http://www.cse.dmu.ac.uk/~mward/martin/papers/ for
[I agree that they're different, but contrary to what one might hope,
a translator is certainly no easier to write. -John]
Return to the
Search the comp.compilers archives again.