
Most of the language that uses interpreter are dynamic and scripting languages. Language program that needs more flexibility and programmability uses Interpreter. The compiler is mostly used by the program that needs high performance. Its execution is slower than the compiler. We need to interpret every time to run the program. So it is easy to debug interpreted language code.Īs compilation happens only once, it runs faster while execution. So it is hard to debug the compiled language code.Īs it scans each statement, it throws an error if it occurs at any statement.
Difference between compiler and interpreter code#
So it is less prone to error at execution time.Īs it executes code one by one statement, the run-time errors can occur.Įrrors are generated after analyzing the complete program. It reads each statement at once and translates it into another language.Īll the errors are spotted at compilation time. It scans complete program in one shot and translates it into machine level language. So it is easy to debug interpreted language code.Language program that needs more flexibility and programmability uses Interpreter. So it is hard to debug the compiled language code.As it scans each statement, it throws an error if it occurs at any statement. So it is less prone to error at execution time. As it executes code one by one statement, the run-time errors can occur. Intermediate code is not generated by the interpreter. There is a difference between compiler and interpreter, the way it executes the program. Difference between Compiler and Interpreter: If you are willing to learn, I have shared an article, how does computer network work in simple word. The result from the last instruction will be displayed as output to the user.

Likewise, it follows all the instructions one by one and executes. The controller moves to next instruction and performs addition operation (n+10). It accepts the input and saved in variable ‘n’. In above example, it translates first instruction and asks a user for input. For each instruction, it generates machine level code and executes. In a case of an interpreter, it goes through each instruction. We can repeatedly run this program with multiple user inputs without any more compilation. The result of the formula will be displayed as output to the user. The value of ‘n’ gets substituted in the formulae. When the user runs it, it asks for user input and saves in variable ‘n’. The user needs to run executable object explicitly. Next job is to execute compiled target file. Now the job of the compiler is completed. This compilation process happens only once. It generates the executable object file (machine level language program). Before getting input from a user, it compiles all the program code and saved formula something like as ((n+10)5 -100)/3. In the above sample program, a very first instruction is to accept input from the user.

How do actually Compiler and Interpreter work? Now lets, keep it simple with below example. Note: Compiler and interpreter are itself software program, that converts the program from one language to other. (It does not wait for the complete program to translate.) It reads the high-level program code line by line and translates it into machine level code and at the same time, it executes each line. The interpreter is radically different from the compiler. You need to run executable object separately. You need toĮxecution does not carry out while compilation phase. Execution is not carried out while compilation phase. The process of compiling a code is called as a compilation. This conversion happens in the single shot and gives executable file.

The compiler is a translator that simply convert the program from one language to another language, from high-level language to machine level language. This translator is of two types compiler and interpreter.īefore knowing the difference between Compiler and Interpreter, just go through what is compiler and interpreter. To run any program on the computer, you need some translator that will convert high-level language to machine level language. Machine level language: As Computer knows only 0 and 1 (on/off signal), a high-level language is not understood by the computer. It is mostly like English type and can not be understood by the machine. High-level language: It is written by the human (programmer). Basically, from human and machine point of view, there are high-level languages and machine level languages.

I start with some brief prerequisite introduction.
