Compiler and interpreter Both translate one form of language into the other form. The Major Difference Between a Compiler and an Interpreter is that A Compiler translates the high-level language program into a machine language or low-level language at once and makes a separate object file while the interpreter translates the high-level program into a machine language without making a separate file.
|The compiler is a program that translates the high-level language program into machine language or low-level language at once.||The interpreter is a program that translates the high-level program into machine language.|
|The compiler translates the whole program into machine language at once.||The interpreter translates the program every time you will execute because it translates one instruction at a time.|
|The compiler makes a separate object file for the translated program.||The interpreter does not make any object file.|
|It works on the complete program at once and takes the entire program as input.||Works line by line and take one statement at a single time as an input.|
|Generates intermediate code which is known as object code or machine code.||It does not generate object code or machine code.|
|Always executes conditional control statements like if-else and logical constructs faster than interpreter.||It executes conditional control statements at very low speed.|
|Because the entire object code has to reside in memory, compiler programs take more memory than interpreter.||Interpreter programs are more memory efficient because they do not generate intermediate object code.|
|Compile once and run anytime and did not need to be compiled every time. E||They are interpreted line by line so they need to be compiled every time.|
|Syntactical and other errors are reported after the entire program is checked.||Error is reported as soon as the first error is occurred and did not work further until the error is not fixed.|
|Their language is more difficult to debug.||Because it reports error as quickly and stops working so that debugging is easy as compared to compiler.|
|Do not allow programs to run until the error is not completely free.||Runs the program from the first line and stops execution until it encounters an error.|
|Languages are more efficient but difficult to debug.||Less efficient languages but easy to debug which makes an ideal situation and choice for new students.|
|Common examples are: C, C++, COBOL||Examples are: BASIC, Visual Basic, Ruby, Python, Lisp, MatLab, PHP|
|The compiler is good for professionals||The interpreter is good for beginners|
|It is faster||It is slower|
|Intermediate code is generated||Intermediate code is not generated|
What is a Compiler?
A compiler is computer software (usually a program) that translates a high-level programing language to a machine language.it can read a program in one written language which is called source language which can translate into object language. a simple representation of compiler can be defined as:
source code —->Compiler—->machine language ( or object file).
Examples of Compiler
there are many examples you can use as a computer programmer. GNU Java, C++ Builder are some common examples of compilers.
- A java compiler for Apple Macintosh
- A COBOL Compiler for the SUN
- A C++ Compiler for the Apple Macintosh
What is Interpreter?
An interpreter is a very relevant program to the compiler which converts high-level language or source code into executable code.it translates high-level instructions into an intermediate form that can be executed. it depends on how much time is available and how many languages are you using.
Examples of Interpreter
interpreter are time saving and used by many professionals. therefore, many varieties of compilers are available nowadays. some common examples are: