Compiler vs Interpreter

Understand how compilers and interpreters translate source code and how their execution processes differ.

Lesson content

Compiler vs Interpreter Compiler Interpreter Translates the complete program before execution Translates and executes code instruction by instruction Usually reports compilation errors before the program runs Usually reports an error when execution reaches it Can generate machine code, bytecode, or another output file Usually executes the translated code through a runtime Compiled output can run faster after translation Execution may include translation work at runtime Examples: C and C++ compilers Examples: traditional Python interpreters Important Note Modern languages do not always fit into only one category. JavaScript and Python runtimes may combine compilation, bytecode, interpretation, and just-in-time compilation. Easy Formula Compiler = Translate Program → Produce Output → Execute Interpreter = Read Instruction → Translate → Execute