Docsity

OOPS - Compiler vs Interpreter, Study notes of Object Oriented Programming

Partial preview of the text

Download OOPS - Compiler vs Interpreter and more Study notes Object Oriented Programming in PDF only on Docsity!

Comparison of interpreters and

compilers

Compiler

 With compilation, some source program P

written in some source language L is

translated into an equivalent program P0 in

some target language L0.

Interpreter

 (^) An interpreter is also a program that translates a

high-level language into a low-level one, but it does it at the moment the program is run.

 (^) You write the program using a text editor or

something similar, and then instruct the interpreter to run the program.

 (^) It takes the program, one line at a time, and

translates each line before running it: It translates the first line and runs it, then translates the second line and runs it etc.

Interpreter

Compiler VS Interpreter

Spends a lot of time analyzing and processing the program

Relatively little time is spent analyzing and processing the program

The resulting executable is some form of machine- specific binary code

The resulting code is some sort of intermediate code

The computer hardware interprets (executes) the resulting code

The resulting code is interpreted by another program

program execution is fast Program execution is relatively slow

Compile VS Interpreter

We can spot syntax errors while the program is being compiled (i.e. you are informed of any grammatical errors before you try to run the program).

Errors are spotted only after the execution of the program

Not much portable when compared to interpreter

They tend to be more "portable", which means that they will run on a greater variety of machines. This is because each machine can have its own interpreter for that language.