15 Difference Between Assembler, Compiler And Interpreter

SHARE

In conventional computers, translation of the program or the source code into object/machine code is done by various methods which include assembler, compiler and interpreter. Below are the underlying details of how they differ from one another.

 What You Need To Know About Assembler

An assembler is a program that takes basic computer instruction or instructions and then converts them into a pattern of bits that the computer processor can use to perform its basic operations. Usually, language used to program the assembler is referred to as assembly language. Assembler converts source code to an object code first then it converts the object code to machine language with the help of the linker programs.

Details About Assembler

  1. Assembler converts source code written in assembly language into machine code and then that machine code is executed by a computer.
  2. Assembler converts assembly language to machine language at once.
  3. It converts a source code to an object first then it converts the object code to machine language with the linker programs.
  4. Input to the assembler is assembly language code.
  5. GAS, GNU is an example of an assembler.
  6. At the output of assembler is re-locatable machine code generated by an assembler is represented by binary code.
  7. Assembler cannot convert the whole code into machine language at once.
  8. Assembler is less intelligent than compiler.
  9. Assembler makes two phases over the given input first phase and the second phase.
  10. It is difficult to debugging.

What You Need To Know About Complier

A compiler is a computer program that transforms source code written in programming language into machine language and then executes it.  Normally, Compilers can take time because they have to translate high-level code to lower-level machine language at once and then save the executable object code to the memory. Also in a compiler, after conversion of all the code at once an error report for the whole program is generated.

Compilers can be classified based on what function it performs or how it has been constructed. Compilers can be classified as single-pass, load-and-go, debugging, multi-pass and optimization.

Compilation is performed in the following phases: lexical analyzer, syntax analyzer, semantic analyzer, intermediate code generator, code optimizer, symbol table and error handle.

Details About Compiler

  1. A compiler converts high-level language program code into machine language and then executes it. High-level languages are C and C#
  2. Complier scans the entire program first before translating into machine code.
  3. Compiler takes entire program as input.
  4. Intermediate object code is generated in case of compiler.
  5. Compiler takes less execution time when compared to interpreter.
  6. Examples include C, COBOL, C#, C++, etc
  7. Compiler requires more memory than interpreter.
  8. If you happen to make any modification in program you have to recompile entire program i.e scan the whole program every time after modification.
  9. Compiler is faster when compared to interpreter.
  10. There is usually no need to compile program every time (if not modified) at execution time.
  11. Compiler gives you the list of all errors after compilation of whole program.
  12. Compiler converts the entire program to machine code when all errors are removed execution takes place.
  13. Compiler is slow for debugging because errors are displayed after entire program has been checked.
  14. The assembly code generated by the compiler is a mnemonic version of machine code.

What You Need To Know About Interpreter

Interpreter is a computer program that translates high level instructions into an intermediate form and then converts that intermediate code into machine language and; carries out specific actions. Interpreters are often used in software development tools as debugging tools because they can execute a single code at a time. In Java language, compiler and interpreter work together to generate machine code.

Details About Interpreter

  1. Interpreter converts source code into the intermediate form and then converts that intermediate code into machine language. The intermediate code looks same as assembler code.
  2. Interpreter scans and translates the program line by line to equivalent machine code.
  3. Interpreter takes single instruction as input.
  4. In case of interpreter, No intermediate object code is generated.
  5. Interpreter takes more execution time when compared to compiler.
  6. Examples include Python, Perl, VB, PostScript, LISP etc.
  7. Interpreter needs less memory when compared to compiler.
  8. If you make any modification and if that line has not been scanned then no need to recompile entire program.
  9. Interpreter is slower when compared to compiler.
  10. Every time program is scanned and translated at execution time.
  11. Interpreter stops the translation at the error generation and will continue when error get solved.
  12. Each time the program is executed; every line is checked for error and then converted into equivalent machine code.
  13. Interpreter is good for fast debugging. An interpreter continues translating the program until the first error is arrived at, in which case it stops.
  14. At the output of assembler is re-locatable machine code generated by an assembler represented by binary code.

Difference Between Assembler, Compiler And Interpreter In Tabular Form

Assembler Vs Compiler

BASIS OF COMPARISON ASSEMBLER COMPILER  
Conversion Assembler converts the assembly code into the machine code. Compiler converts the source code written by the programmer to a machine level language.
Input Assembler inputs source code.   Compiler inputs is preprocessed source code.
The output The output of assembler is binary code. The output of compiler is a mnemonic version of machine code.
Examples GAS
GNU
C
C#
Java
C++
Debugging Debugging is difficult.   Debugging is easy.
Working Assembler converts source code to an object code first then it converts the object code to the machine language with the help of linker programs. Complier scans the entire program first before translating into machine code.  
Intelligence Assembler is less intelligent than a compiler. Compiler is more intelligent than assembler.
Working Phases Assembler makes works in two phases over the given input. The phases are:
First Phase
Second Phase
The compilation phases are:
Lexical analyzer
Syntax analyzer
Semantic analyzer
Code optimizer
Code generator
Error handler

Compiler Vs Interpreter

BASIS OF COMPARISON COMPILER INTERPRETER
Function A compiler converts high-level language program code into machine language and then executes it. Interpreter converts source code into the intermediate form and then converts that intermediate code into machine language
Scanning Complier scans the entire program first before translating into machine code.   Interpreter scans and translates the program line by line to equivalent machine code.  
Working Compiler takes entire program as input.   Interpreter takes single instruction as input.  
Code Generation Intermediate object code is generated in case of compiler.   In case of interpreter, No intermediate object code is generated.  
Execution Time Compiler takes less execution time when compared to interpreter.   Interpreter takes more execution time when compared to compiler.  
Examples C
COBOL
C#
C++, etc  
 Python
Perl
VB
PostScript
LISP etc.  
Memory Requirement Compiler requires more memory than interpreter.   Interpreter needs less memory when compared to compiler.  
Modification If you happen to make any modification in program you have to recompile entire program i.e scan the whole program every time after modification.   If you make any modification and if that line has not been scanned then no need to recompile entire program.  
Speed Compiler is faster when compared to interpreter.   Interpreter is slower when compared to compiler.  
At Execution There is usually no need to compile program every time (if not modified) at execution time.   Every time program is scanned and translated at execution time.  
Error Detection Compiler gives you the list of all errors after compilation of whole program.   Interpreter stops the translation at the error generation and will continue when error get solved.  
Machine Code Compiler converts the entire program to machine code when all errors are removed execution takes place.   Each time the program is executed; every line is checked for error and then converted into equivalent machine code.  
Debugging Compiler is slow for debugging because errors are displayed after entire program has been checked.   Interpreter is good for fast debugging.
Code Version The assembly code generated by the compiler is a mnemonic version of machine code.   At the output of assembler is re-locatable machine code generated by an assembler represented by binary code.