Translators, Compilers & Interpreters Flashcards

Card 1 of 8

All 8 cards in this deck

What is the purpose of a translator?

To convert source code into machine code so that the computer can execute the program.

Why do programs written in a high-level language need a translator?

Because a processor can only execute machine code (binary instructions), so high-level source code cannot be run directly.

Describe the characteristics of a compiler.

It translates the whole program in one go before it is run, produces an executable file, and reports all errors together at the end of compilation.

Describe the characteristics of an interpreter.

It translates and executes the program one line at a time, stops execution when it finds an error, and produces no executable file.

Give two benefits of using a compiler instead of an interpreter.

It produces an executable file, so end users do not need a translator; the program runs faster than the interpreted version.
Also: it only needs translating once, and the compiler can optimise the code.

A programmer is still writing and testing a program, changing it after every run. Should they use a compiler or an interpreter, and why?

An interpreter — it runs the code straight away without re-translating the whole program, and stops at the error so its location is easy to find.

Give two drawbacks of using a compiler.

Any two of: translating the whole program can take a long time; errors are only reported, all together, after compilation finishes, which can make them harder to track down; the program must be recompiled after every change.

Give two drawbacks of using an interpreter.

Any two of: the program runs more slowly, because each line is translated every time it runs; the interpreter must be present every time the program is run; the source code has to be given to users, so it can be seen and copied.