Evaluate the translation processes of interpreters and compilers
Translation = changing source code into machine executable instructions. Two main methods: interpreted and compiled . Hybrids include JIT compilation and…
6 min read1,285 words
Key Vocabulary
Term
Definition
Machine instructions / code / language
The most basic commands the CPU directly executes. Encoded in binary; specific to the processor architecture (x86, ARM, MIPS).
Assembly language
A slightly more readable form of machine code. Uses mnemonics (e.g., MOV, ADD) and labels instead of raw addresses.
Compiler
Translates code into machine code before execution.
Interpreter
Reads and translates code line by line as the program runs. No intermediate binary executable.
Translation
Converting human-readable code into machine instructions.
Programming language
A formal system (lexicon) of instructions and syntax computers can execute.
Binary executable
A file containing machine code that an OS (Windows/macOS/Linux) can load and run directly.
Bytecode
An instruction set designed for efficient execution by a software interpreter (a virtual machine).
Parser
Analyzes input according to grammar rules; decomposes it into a hierarchical structure (parse tree / AST).
Semantics
The precise meaning of programming constructs — “what does this instruction do?”
Standard library
Pre-written modules/classes/functions distributed with the language.
An interpreted language is translated into machine code line by line, as the program runs. The interpreter reads, interprets, and executes each line in sequence.
Stops at the first error → useful for debugging.
Generally slower than compiled (translation happens at runtime).
Often uses less memory — no output executable; reads source directly.
Highly platform-independent — the interpreter sits between source code and the OS’s machine code.
Examples: Python, PHP, Ruby, JavaScript.
Steps of Interpretation (Python example: print("Hello World!"))
Step
Description
Initiate execution
User runs the program (IDE “Run”, double-click, CLI).
A parser verifies tokens against the language’s grammar rules (e.g., function name + parentheses + arguments).
Semantic analysis
Checks for semantic errors — type mismatches, undeclared variables, valid function calls.
Code generation
Source translated into bytecode (intermediate, platform-independent, for the Python VM).
Execution
Interpreter executes bytecode one instruction at a time — fetch, decode, execute.
Use Case for Interpreted Languages
Fast feedback loop: no compile-run cycle → faster iteration.
Dynamic typing: variables can hold any type at runtime → less boilerplate.
Platform-independent: any OS with the interpreter installed can run the script.
Rich standard libraries + ecosystems (e.g., Python for data science, ML, automation).
Ideal for rapid development, scripting, prototyping, exploratory work.
Compiled Languages
A compiled language is translated from source code to machine code in its entirety, before execution, producing a binary executable the CPU can run directly.
Errors caught at compile time → executable is not generated until errors are resolved. Less interactive debugging.
Faster execution — code is already machine code; no real-time translation.
Higher memory use during compilation, but efficient at runtime.
Less platform-independent — executable is OS- and hardware-specific; needs separate compilation per platform.