Compiler VS Interpreter
C++ with Vatsal
This series will introduce you to the basics of C++ with some moderate and possibly advanced concepts with some interesting relatable examples to make it more interacting and fun. Let's Begin!!
Compiler VS Interpreter
--> INTRODUCTION
What is Compiler??
A compiler is a computer program which helps you transform source code written in a high-level language into low-level machine language.
What is Interpreter??
An interpreter is a computer program that executes each of a set of high-level instructions before going to the next instruction.
Languages Supporting:
COMPILER:- C, C++, Erlang, Haskell, Rust, and Go
INTERPRETER:- PHP, Ruby, Python, and JavaScript
Difference between Source code & Machine code:-
We generally write a computer program using a high-level language. A high-level language is one that is understandable by us, humans. This is called source code.
However, a computer does not understand high-level language. It only understands the program written in 0's and 1's in binary, called the machine code.
Fun Fact: Is it possible to write a program with only 1's and 0's in it????
Solution: It is actually possible but it is pretty complex. Let's see an example.......
--> Working
COMPILER:-
- Compiler scans the entire program and translates the whole of it into machine code at once.
- A compiler takes a lot of time to analyze the source code. However, the overall time taken to execute the process is much faster.
- A compiler always generates an intermediary object code. It will need further linking. Hence more memory is needed.
- A compiler generates the error message only after it scans the complete program and hence debugging is relatively harder while working with a compiler.
- Interpreter translates just one statement of the program at a time into machine code.
- An interpreter takes very less time to analyze the source code. However, the overall time to execute the process is much slower.
- An interpreter does not generate an intermediary code. Hence, an interpreter is highly efficient in terms of its memory.
- Keeps translating the program continuously till the first error is confronted. If any error is spotted, it stops working and hence debugging becomes easy.
COMPARISON:- More Efficient: 👍
Less Efficient: 👎
Time taken to execute the source code: Compiler 👎 Interpreter 👍
Overall time taken: Compiler 👍 Interpreter 👎
Memory efficiency: Compiler 👎 Interpreter 👍
Ease in debugging: Compiler 👎 Interpreter 👍
Comments
Post a Comment