Interpreter and Compiler in Java

Interpretation and Compilation:

Before starting with the Programming concepts, let us first introduce you to two important terms: Compilation and Interpretation.

Compilation and Interpretation: You may think they are synonymous and mean the same thing – Translation.

Well, you’re right up to a point, both means Language Translation but technically there’s a huge difference.

Suppose you are a language translator for a foreign language – say, French.

Now if the French President arrives in your country and delivers a speech, it would be quite impractical to think that the public will understand it.

Neither the French President could be requested to deliver an entire speech in the local language.

So, your job is to translate the speech into the local language. There may be two solutions to the problem:

  • The French President delivers a sentence of his speech. You’ll immediately translate to the local language. Again he speaks a line. You follow him, translating the sentence.
    This process of translation is called INTERPRETATION.
  • The French President delivers the entire speech at a go. After he has completed, the translator will translate the entire speech in the local language and deliver it all together.
    This process of translation is called COMPILATION.

Now you may think, why do we even need a Translator for Java?

The fact is: The computer doesn’t even understand Java Language. The computer understands only two things: 0 and 1 – The Binary Language.

Binary Language is the lowest level of language possible. It comprises of 0 and 1 and everything is represented in combinations of 0’s and 1’s.

Thus we need a translator or rather a compiler/ interpreter to make the Computer understand we are writing. Thus using compiler and interpreter, we are converting all the instructions written in the high-level language to machine level language.

The compiler translates all the instructions at once, lists the errors, asks the users to debug them and then converts the original instruction into instruction that could be understood by the computer.

The interpreter translates the instructions line by line. If an error is found stops the execution until it is corrected and then resumes the execution.

This process of error correction is much easier since the error is particularly pointed out but takes a longer time.

Interpreter and Compiler in Java