Explain Difference between complier & interpreter
Answers
In contrast with a compiler, an interpreter is a program which imitates the execution of programs written in a source language. Another difference between Compiler and interpreter is that Compiler converts the whole program in one go on the other hand Interpreter converts the program by taking a single line at a time.
Compiler
A complier is a computer program which converts the High level programming language to Low level programming language or Machine language. The codes written in the High level programming language in a computer are turned into the Machine level programming language by complier. A computer system cannot understand the high programming language, Hence it is necessary to convert the programming language to Low level programming or Machine level language.
A computer system can only understand the Machine level language and Binary codes. This language is in the form of Binary codes in the form of "0,1". A computer can understand only the language of binary code.
When a programmer simply writes a code or program in the text editor by using programming languages like C and Python. This files containing the code are called as "Source statement". When the code has to be executed, The compiler parses the High level programme to the low level programme, This process is also called as Parsing.
Each and every line passes through the complier and after the execution of all lines, The output code is created in the form of Binary code. This output of the object is also called as 'Object module'. This object code is nothing but the Machine code that processor can process and execute it.
Later, The processed code is sent to the output unit. And this is how the code is executed and output is shown.
Programming languages like Java, C and C++ uses object oriented language. This helps the complier to perform it's work with the help of bytecode in bits of seconds. Rather than it, some programming languages are very high level programming languages which don't use Object Oriented Programming language. This programming languages require more time to get executed. Examples of this programming languages can be given as Python and JavaScript.
Additionally, In some Operating systems like Mac and Linux, one more step is to be done before executing the code which is to "resolve the instructions locations and data" for executing the more code at same time.
A complier contains 2 main parts. 3GL and Assembler. 3GL works with the complier and High level programming languages. And Assembler works on the code written using assembler language by processor.
Interpreter
Interpreter is a computer program which executes the instructions written in High level programming language directly. This process is direct process. Hence, Interpreter is not connected with the internal devices of computer like Processor and Compiler.
There are two methods of writing or executing any code written in High level programming language. One is of Complier ans second one is of the interpreter.
Compiler converts the high level programming language to low level programming language. Whereas, Interpreter directly executes the high level programming language to Low level programming language.