scorecard
  1. Home
  2. Education
  3. Difference between Compiler and Interpreter

Difference between Compiler and Interpreter

Difference between Compiler and Interpreter
Compliers and interpreters are programs that help convert the high level language (Source Code) into machine codes to be understood by the computers. Computer programs are usually written on high level languages. A high level language is one that can be understood by humans. To make it clear, they contain words and phrases from the languages in common use – English or other languages for example. However, computers cannot understand high level languages as we humans do. They can only understand the programs that are developed in binary systems known as a machine code. To start with, a computer program is usually written in high level language described as a source code. These source codes must be converted into machine language and here comes the role of compilers and interpreters.

Differences between Interpreter and Compiler

Interpreter translates just one statement of the program at a time into machine code.

Compiler scans the entire program and translates the whole of it into machine code at once.

An interpreter takes very less time to analyze the source code. However, the overall time to execute the process is much slower.

A compiler takes a lot of time to analyze the source code. However, the overall time taken to execute the process is much faster.

An interpreter does not generate an intermediary code. Hence, an interpreter is highly efficient in terms of its memory.

A compiler always generates an intermediary object code. It will need further linking. Hence more memory is needed.

Keeps translating the program continuously till the first error is confronted. If any error is spotted, it stops working and hence debugging becomes easy.

A compiler generates the error message only after it scans the complete program and hence debugging is relatively harder while working with a compiler.

Interpreters are used by programming languages like Ruby and Python for example.

Compliers are used by programming languages like C and C++ for example.



How Interpreter and Compiler work?

To start with, a compiler creates the program. It will analyze all the language statements to check if they are correct. If it comes across something incorrect, it will give an error message. If there are no errors spotted, the compiler will convert the source code into machine code. The compiler links the different code files into programs that can be run such as exe. Finally the program runs.

An interpreter creates the program. It neither links the files nor generates machine code. The source statements are executed line by line while executing the program.

Advantages and disadvantages of Interpreter and Compiler

In case of using compilers, the program codes are translated into machine code already and hence the time to execute the code is very less. On the negative side, it is not possible to change the program without going back to the source code while working with a compiler.

Interpreters make working with the source code much easier. Hence they are highly suitable especially for the beginners. On the negative side, interpreted programs can only run on the computers that have the respective interpreters.

READ MORE ARTICLES ON



Popular Right Now



Advertisement