STOP IT! There are no Compiled and Interpreted Languages!
There is no such thing as compiled languages and interpreter languages. They are just implementations for the language.
A single language can have more than one use of compilers and interpreters working together to produce the final output.
Compiler:
Compiler converts one language to another language.
source program →| compiler | →Target program
At this stage, code optimisations are done if it is capable/required.
Compiling doesn’t execute the program.
If the target language is machine code, it can be executed directly on the processor.
input →| target program | →output
Now a days, most of the compilers translate source code to machine independent byte-code.
Then the byte-code is interpreted at run-time and executed using interpreters and JIT.
Interpreter:
Interpreter executes the source program or target program( got from compilation step ) one statement at a time.
Code optimisation is not possible because it scans each line executes it. So there is no possibility to see ahead of the current line and optimise it.
source/target program, input →| interpreter | → output
In the background, even the compiled programs( C, C++ etc) are interpreted. There is an interpreter running the binary file which is implemented by the underlying processor.
A CPU can be viewed as a hardware-based interpreter for its machine code.
A VM can be view as a software-based interpreter.
Example:
Python can be converted into byte-code and then executed by interpreting the intermediate byte-code or can be executed directly without converting it to byte-code.
So, there are no compiled languages or interpreted languages technically! It states only the implementation of the language.