TEchMyEducation

easy tech learning...

compiler vs interpreter

No comments

compiler vs interpreter

Difference between Compiler and Interpreter

Programmers typically write computer programs using a high-level language. A high-level language is a language that a user can understand. The language that the user understands is called source code. However, the computer does not understand high-level language. The computer only understands 0 and 1 binary numbers called machine codes.

To convert source code and high-level language into machine code, both compiler or interpreter are used. But there are differences between how the compiler or interpreter works. The compiler is a translator that converts source code (high-level language) into machine language. Whereas Interpreter is a program that mimics the execution of a program written in source code. The main difference between a compiler and an interpreter is that the compiler translates the entire program at once and tells whatever error occurs while the interpreter translates one line and if there is an error in a line, as long as that error is not fixed, it does not proceed.

What is Compiler?

The compiler is a translator that converts source code (high-level language) into machine language. It translates the source code into machine code to create an executable file. 

The programmer can execute this object file after copying it to another computer. In other words, after the program is compiled it becomes an independently executable file that does not require a compiler to execute.

What is an Interpreter?

An interpreter is a program that performs the task of converting programs written in a high-level language into machine language. The interpreter translates each instruction into machine language alternately. It does not translate all the instruction of high-level language programs into machine language simultaneously.

What is Assembler

Assembler is a program that translates assembly language into machine language & nbsp; Is Apart from this, it translates high-level language into machine language. The assembler can convert mnemonic code such as ADD, NOV, SUB, etc. into binary code.

Difference between compiler and interpreter

compiler vs interpreter

#CompilerInterpreter
1.Compiler scans the whole program in one go.Translates program one statement at a time.
2.As it scans the whole code in one go, the errors (if any) are shown at the end together.it scans code one line at a time, and errors are shown line by line.
3.Main advantage of compilers is it’s execution time.Interpreters being slow in executing the object code, so it is less preferred.
4.It converts the source code into object code.it scans it line by line
5



6



7


8
It does not require source code for later execution.

If there is an error in the syntax of the program the compiler tells the error later.

Intermediate object code is generated in it so memory is used in it.

Debugging is not easy 

It requires source code for later execution.


The interpreter translates each line and if an error is present in a line, it does not proceed until the error is corrected.

It does not generate any intermediate object code, so it uses less memory.

It is easy to debug

Eg.C, C++, C# etc.Python, Ruby, Perl, SNOBOL, MATLAB, etc.


A significant difference between compiler and interpreter 

  • The compiler translates the entire program, but the interpreter translates the program with a single line.
  • The compiler is comparatively faster than the interpreter because the compiler can translate the entire program at once while the interpreter compiles each line of code one after the other.
  • The compiler requires more memory than the interpreter due to the generation of object code.
  • The compiler shows all the errors at once while the interpreter translates one line and shows the error.
  • When an error occurs in the program in the compiler, it stops the program and re-translates the entire program after correcting the error. In contrast, the interpreter translates a line and if an error occurs, it stops its translation and translates only after removing the error.
  • compiler process is a two-step process in which the source code is first translated to the target program and then executed. Whereas Interpreter, it processes a step in which the source code is compiled and executed at the same time.
  • The compiler is used in programming languages ​​such as C, C ++, C #, Scala, etc. While Interpreter is used in PHP, Ruby, Python, etc. languages.

References:
http://en.wikipedia.org/wiki/Interpreter_%28computing%29
http://en.wikipedia.org/wiki/Compiler

TechMyEducation

#difference between compiler and interpreter

No comments :

Post a Comment