TOPIC 3.3. BASIC
TRANSLATION PROCESS
There are two types of translator
for converting a high level language such as PASCAL into machine code:
- Compilers; and
- Interpreters
|
 |
- Compilers and interpreters are the type of
the translation.
- The text typed in by the programmer with the
aid of the editor is known as the source code and this has to be
translated by either a compiler or an interpreter into machine code or
object code.
|
| The
translation process is an activity during which the translator
establishes equivalences between a text, or segments of a text, and another
language.
The translation process can be described simply
as:
- Decoding the meaning of the source text
(source language), and
- Re-encoding this meaning in the target
language (object language).
|
A compiler translates a complete
program into object code before it is executed, whereas an interpreter
analyses the source code statement by statement as execution proceeds,
interpreting the meaning of each statement and calling routines to carry out
each instruction.
Cross-compilers and
cross-assemblers are translators which enable a program to be
compiled or assembled on one machine, and executed on a different type of
processor. This is sometimes useful if, for example, program development is
being done on a mainframe for a program which will eventually be run on a
microcomputer, or in the development of embedded processor programs.
|
ADVANTAGES OF COMPILER |
ADVANTAGES OF AN INTERPRETER |
- A compiled program will almost always run
faster than an interpreted program.
- The object program (the machine code
generated by the compiler) may be saved on disk and run as many times as
required without being recompiled.
- A compiler can give more helpful error
messages; if for example, a keyword (reserved word) is misspelt all
through the program, an interpreter will only find the first instance,
whereas a compiler will list them all.
- A compiler will check the syntax of the
entire program, whereas an interpreter will only check the syntax of the
statements that are executed during that particular run of the program.
Certain branches of the program may therefore not be checked until very
thorough testing takes place.
- Commercially produced software can be sold
in the form of object code, thus preventing purchasers from listing the
source code or making modifications to it.
|
- Interpreters are very convenient for program
development, since making modifications does not mean that the whole
program has to be reloaded and recompiled, which can take a considerable
time. Many interpreters will allow a program to run up to the point where
an error occurs, let the programmer fix the error and then continue to run
the program from that point.
- An interpreter is simpler to write and is
usually cheaper to buy than a compiler.
|
| |
| |
RESOURCE: P M Heathcote, [A level Computing,
3rd Edition], Ashford Colour Press Ltd, 1996