Software Types and Language Translators: Question 10
Syllabus 4.2
A games company wants the final, released version of its game to run as fast as possible on a player's console, since exactly the same code will be run over and over again with no further changes made to it.
Which statement explains why using a compiler, rather than an interpreter, for this final release best supports that goal?
Show worked solution Hide worked solution
Worked solution
Step 1: Recall how a compiler produces its output
A compiler translates an entire high-level program into machine code in one complete pass, before the program is ever executed, producing a stand-alone file of object code. Once this translation has happened, that machine code file can be run directly by the console’s processor as many times as needed, without the translation step being repeated.
Step 2: Test each option against this fact
- Option A describes translating and executing line by line, which is how an interpreter behaves, not a compiler, so it is incorrect.
- Option B correctly states that the compiler’s one-off translation, done before the game is ever played, means the console only ever executes ready-made machine code, with no translation overhead repeated during play.
- Option C is incorrect because a compiler translates every line of the whole program, not only the lines containing errors.
- Option D describes needing the original source code present to be re-translated on every run, which is a feature of using an interpreter, not how a compiler’s released executable file works.
Step 3: Confirm the match
Because translation happens only once, before release, and the console then just executes ready-made machine code every time the game is played, repeated translation overhead is avoided, unlike an interpreter, which would translate the code again on every single run. This is exactly what the games company wants for code that will be run over and over with no further changes.
Final answer
The correct statement is option B: a compiler produces machine code once, before release, so the console can execute it directly every time without repeating any translation.