Interpreting is generally more convenient for cross-platform development, because the same source code can run on different operating systems and processor architectures when each platform has a suitable interpreter. However, compiled languages can also be cross-platform if the source code is recompiled for every target platform.
The Reasoning
A compiler translates an entire source program into machine code before execution. Because machine code is designed for a particular instruction set and operating environment, the resulting executable is usually platform-specific.
An interpreter translates and executes source code instruction by instruction at runtime. The source code remains unchanged, while a platform-specific interpreter handles the differences between systems. This improves portability, although interpreted execution is generally slower because translation occurs during runtime.
| Translation method | Cross-platform implications |
|---|---|
| Compilation to native machine code | A separate executable usually must be compiled for each operating system and processor architecture. |
| Interpretation | The same source code can run wherever a compatible interpreter is installed. |
| Compilation to intermediate code | A virtual machine executes the intermediate code on each platform, combining portability with some compilation benefits. |
For example, a program compiled directly for an ARM processor will not normally execute on an x86 processor. By contrast, a Python program may run on both processors if each system has an appropriate Python interpreter.
Some systems use a hybrid approach. Java source code, for example, is compiled into bytecode, which is then executed by a platform-specific Java Virtual Machine. This allows the same bytecode to operate across multiple platforms.
A common misconception is that compiled languages cannot support cross-platform development. They can, but developers usually need separate compilation, compatible libraries, and sometimes platform-specific code for each target environment.
Exam Technique
For A1.4 Translation (HL only), compare both methods rather than claiming one is always better. Link interpretation to portability and runtime translation, then link compilation to platform-specific machine code and faster execution. If the command term is evaluate, give a balanced conclusion based on the development context.