Both Compiler and Interpreter work to convert high-level language to machine understandable code and then back to high-level code, but there are some differences in their working.
Difference between Compiler and Interpreter are:
Compiler | Interpreter |
---|---|
It considers the completion of your program as input for converting to machine code. | It considers 1 statement in your program at a time as input for converting to machine code. |
It usually generates intermediate code in the form of the object file (.obj). | It doesn't create an intermediate object (.obj) code. |
Faster execution of control statements as compared to the interpreter. | Slower execution of control statements as compared to the compiler. |
Detected errors in the program get displayed after the entire program is read by compiler. | Detected errors in the program get displayed after each instruction read by the interpreter. |
Example: C++, Java. | Example. BASIC, Python, PHP. |