Tuesday, October 25, 2022

Compiler and Interpreter

Compiler and Interpreter

Content:

  • Introduction
  • Compiler
  • Interpreter
  • Compiler VS Interpreter

Introduction:

Both compiler and interpreter are Language Processor. A language processor is a special type of a computer software that can translate the source code into object code or machine code.

Source Code: it refers to the program-code written by a programmer in a high level programming language(HLL) such as python

Object Code:It refers to a code usually in machine language or binary code, that computer can understand and run on hardware.

Compiler:

Compiler converts the source code into machine code. If the code follows all syntactic rules of the language, then it is executed by the computer. Once translated, the compiler is not needed. Example of compiled language:C, C++ etc.

compiler.JPG

Interpreter:

An interpreter translates one line at a time instead of the whole program at one go. Interpreter takes one line, converts it into executable code if the line is syntactically correct, and then it repeats these steps for all lines in the source code. Hence, interpreter is always needed whenever a source code is to be executed.Example of interpreted language:Javascript, python etc.

interpreter.JPG

Difference Between Compiler and Interpreter:

Compiler
Interpreter
The compiler is not required once executable is generated Interpreter is required through out the process of execution
Any changes in the source code needs the process of compilation to be repeated from the start, so changes in the code is not as friendly as interpreter. Any changes in the source code can be accommodated easily 
All the errors in the code is displayed all together It displays the error line by line and not at once.
Example: C, C++, C# Example: Python, javascript,PHP

Reference:

  1. Ncert Text book Class 11
In [ ]:
 
Share: