Translators, Compilers & Interpreters Flashcards

All 6 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.
e.g. also accepted: 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.