Difference b/w Compiler Interpreter and Assembler
Difference b/w Compiler Interpreter and Assembler
Here’s a clear and concise comparison between Compiler, Interpreter, and Assembler, including their definitions, differences, and a table for quick revision.
Contents
🔧 1. Compiler
- 🔹 Definition: A compiler is a program that translates the entire source code of a high-level language (like C, C++, Java) into machine code (binary) at once.
- 🔹 Output: Generates an executable file (.exe).
- 🔹 Execution Speed: Fast (after compilation).
- 🔹 Example Languages: C, C++, Java (partially).
🧮 2. Interpreter
- 🔹 Definition: An interpreter translates line-by-line of source code into machine code and executes it immediately.
- 🔹 Output: No executable file is created.
- 🔹 Execution Speed: Slower (interprets each line every time).
- 🔹 Example Languages: Python, JavaScript, Ruby.
⚙️ 3. Assembler
- 🔹 Definition: An assembler converts assembly language (low-level language) into machine code.
- 🔹 Output: Machine code (binary).
- 🔹 Used For: Assembly language programming (e.g., using instructions like MOV, ADD).
- 🔹 Example: MASM (Microsoft Assembler), NASM.
📊 Comparison Table
Feature | Compiler | Interpreter | Assembler |
---|---|---|---|
Input | High-Level Language | High-Level Language | Assembly Language |
Output | Machine Code / Executable File | Direct Execution | Machine Code |
Execution Style | Translates all at once | Translates one line at a time | Translates all at once |
Speed | Fast (after compilation) | Slower (runs line-by-line) | Fast |
Error Handling | Shows all errors after compilation | Shows errors one by one | Shows all errors after conversion |
Examples | C, C++, Java (JVM compiles bytecode) | Python, JavaScript, BASIC | NASM, MASM |
📌 Summary in One Line:
- Compiler → Full code → Executable
- Interpreter → Line-by-line → Direct Execution
- Assembler → Assembly → Machine Code
If you’d like a PDF summary, visual diagram, or practice questions based on this topic (useful for GATE, NET, B.Tech, etc.), let me know and I’ll prepare that too!