All three are language translators that turn source code into something the machine can run.
- Compiler: translates the whole high-level program (C, C++) into machine code at once, producing an executable. Errors are reported after the whole program is analysed. Phases: lexical analysis, syntax analysis, semantic analysis, intermediate code, optimization, code generation.
- Interpreter: translates and executes the program one statement at a time (Python, JavaScript, BASIC). It stops at the first error; no separate executable is created.
- Assembler: translates assembly language (mnemonics such as MOV, ADD) into machine code, one-to-one.
| Point | Compiler | Interpreter | Assembler |
| Input | High-level language | High-level language | Assembly language |
| Translation unit | Whole program | Line by line | Whole program |
| Output | Executable file | None (runs directly) | Object / machine code |
| Execution speed | Fast | Slower | Fast |
| Error reporting | All after compiling | One at a time, stops | After assembling |
| Memory | More (object code) | Less | Less |
| Examples | GCC, javac | CPython, Node.js | NASM, MASM |
(Java uses both: javac compiles to bytecode, which the JVM interprets and JIT-compiles.)
— rhs