Skip to content

9618 · 5.2

Language Translators — common mistakes

Common exam mistakes on 9618 Language Translators. Learn what loses marks, then practise the topic with Examiner’s Ink.

Exam tip 1

Exam questions frequently ask you to 'compare and contrast' compilers and interpreters. For full marks, you must provide both similarities (e.g., both translate HLLs) and differences (e.g., speed, error handling, output). Use a structured approach, addressing one point of comparison at a time for both translators.

Can a language be both compiled and interpreted?

Yes, this is common in hybrid systems. A prime example is Java. Java source code is first compiled into a platform-independent intermediate code called 'bytecode'. This bytecode is then run on any device that has a Java Virtual Machine (JVM). The JVM acts as an interpreter for the bytecode, translating it into native machine code for the specific processor it's running on.

If compiled code is faster, why does anyone use interpreters?

Interpreters offer significant advantages during the development phase. The rapid feedback loop (write code, run instantly, see error on the exact line) makes debugging much faster. This flexibility and ease of testing often outweigh the performance penalty for many applications, especially in web development, scripting, and data analysis where development speed is a priority.

What happens during syntax analysis if the code is wrong?

If the syntax analyser (parser) receives a stream of tokens that violates the language's grammar rules, it cannot build a valid parse tree. At this point, it will halt the compilation process and generate one or more syntax error messages, which are then reported to the programmer. For example, a missing semicolon or mismatched brackets would be caught at this stage.