Compiling and Execution

Once the program has been written it needs to be converted into machine language (0 and 1), before the machine can execute it. This conversion is done by the compiler. Compiling the program makes an EXE file (Executable file), if we copy this file to another machine we can execute it without recompiling it.

Compiler and Interpreter

What is the Compiler?

A Compiler is a computer program that translates code written in a high-level programming language into machine code usually binary code 0 and 1. The computer processes the machine code to perform the corresponding tasks.

What is the Interpreter?

An Interpreter is a computer program, which translates each high-level program statement into the machine code. This includes source code, pre-compiled code, and scripts. Both compiler and interpreters do the same job which is converting higher level programming language to machine code. However, a compiler will convert the code into machine code (create an EXE) before program run. Interpreters convert code into machine code when the program is run.

compiler and interpreter
Difference between Compilers and Interpreters
S.No. Compiler Interpreter
Scan the entire program and translates it into machine code. Translate program, one statement at a time.
The Compiler generates intermediate object code. The Interpreter does not produce any intermediate object code.
The Compiler takes a large amount of time to analyze the source code, but the overall execution time is comparatively faster. The Interpreter takes less amount of time to analyze the source code, but the overall execution time is slower.
The Compiler generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Continue translating the program until the first error is met, in case an error occurs it stops. Hence debugging is easy.
Programming languages like C, C++, C# uses compiler. Languages like PHP, Python, Perl, Ruby uses an interpreter.

What is Compiler and Interpreter