Press ESC to close

Difference between Compiler and Interpreter

Photo by Markus Winkler

They all are translators and used to convert source code into object code. The main difference between compiler interpreter and assembler is that compiler converts high level language code (Source Code) into machine language code (Object Code) all at once. On the other hand interpreter converts line by line of high level code into machine code. Assembler is used to convert assemble language code into machine language code.

Computer needs set of instructions to perform specific task. These instructions are given to computer through different programming languages.  And the code written in Assembly language and high level language needs to be converting into machine language before execution.  Computer only understands machine language. That’s why compiler interpreter and assembler are used to convert high level code and assembly code to machine level code.

Compiler

Compiler is a language translator that reads data written in high level language and converts it into machine language for execution. A compiler converts the whole program to high level language into machine language. It also reports the error that encounters at time of execution and you have to resolve the error before successful build. It is not possible to build the program without resolving the errors. Most of the high level programming languages such as Java, C and C++ uses compiler for execution.

Interpreter

Interpreter is also a language translator that reads data written in high level language and converts into machine language line by line. The only main difference between compiler and interpreter is that compiler convert’s whole document at once and interpreter converts line by line. The scanning time in interpreter is usually lowers because it checks line by line but execution time is higher as compared to compiler. Many high level programming languages such as Python, PHP and Perl uses interpreter for execution.

Assembler

Assembler has nothing to do with high level language and machine language. It deals with assembly language. Assembly language is in between the machine language and high level language. It is not as much as user friendly like high level language but bit easier to work with. Assembler is also a language translator which converts assembly language code to machine language code for execution.

Conclusion

Compiler interpreter and assembler all are language translator. Two of them are used to convert high level language in to machine language and one of them is used to convert assembly language in machine language. So although they all are intended to do same jobs but all of them have some advantages and disadvantages? Compiler and interpreter have more usage as compared to assembler. So Compiler converts whole code at once in to machine language and interpreter converts line by line.

Leave a Reply

Your email address will not be published. Required fields are marked *