Worked example 1
A software company is developing a high-performance 3D graphics engine for a commercial video game to be sold to the public. Justify, with two distinct reasons, whether a compiler or an interpreter would be more suitable for distributing the final product.
Show solution outline
Translator: Compiler [1 mark]
Justification 1 (Performance): Video games require maximum performance for smooth frame rates and complex calculations. A compiled program is translated into machine code once, allowing it to execute directly on the CPU at high speed. An interpreter would be too slow, as it translates code during runtime, adding significant overhead that would be unacceptable for a graphics engine. [1 mark]
Justification 2 (Intellectual Property): When distributing a commercial product, the company wants to protect its source code. A compiler produces an executable file of machine code, which is extremely difficult to reverse-engineer back into the original source code. Distributing an interpreted script would mean giving away the source code, as the interpreter needs it to run. [1 mark]