We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8
Compiler, Interpreter, and
Assembler Overview and Differences between Compiler and Interpreter Compiler
• - A Compiler is a program that translates source
code written in a high-level programming language into machine code. • - The entire program is translated before execution. • - The output of a compiler is an executable file (e.g., .exe) which can be directly run on the computer. • - Examples: GCC (for C/C++), javac (for Java). Compiler Construction • The process of constructing a compiler is called compiler construction. Why we construct compilers? • Without compilers our machines (computers) will not be able to understand the source code written in high level languages and therefore the requied task will not be executed. Types of languages • All softwares running on the computers were written in some programming language. High level language Low level language Machine language Interpreter
• - An Interpreter directly executes instructions
written in a programming or scripting language. • - It processes the source code line by line, without converting it into machine code in advance. • - Interpreters are generally slower compared to compilers because they execute code at runtime. • - Examples: Python Interpreter, Ruby Interpreter. Assembler
• - An Assembler translates assembly language code
into machine code. • - Assembly language is a low-level programming language that is closely related to machine language. • - Assemblers are crucial for translating human- readable assembly code into executable binary instructions. • - Example: NASM (Netwide Assembler), MASM (Microsoft Assembler). Compiler vs Interpreter
• - **Translation Time**: A compiler translates the entire
program at once before execution, while an interpreter translates and executes code line by line. • - **Speed**: Compiled programs run faster, whereas interpreted programs run slower due to on-the-fly execution. • - **Output**: Compiler generates machine code (e.g., .exe), while an interpreter does not generate an intermediate file. • - **Error Detection**: Compiler checks for errors in the entire code during compilation, while an interpreter stops at the first error and proceeds line by line.