Yash: Today we
were talking about Java. During discussion instructor told that Java is compiled
as well interpreted language.
Me: He is
perfectly correct.
Yash: But what is
Compile and Interpreted?
Me: It is very
easy to understand.
Me: Let’s take a scenario. Recently elected Prime Minister of India,
Narendra Modi receives a letter of congratulations from Japanese Prime Minister,
Shinzo Abe. Japanese PM has letter in
Japanese. Indian PM does not understand Japanese, so one of translator in
Indian PM Office translates the thank you note and pass on to Modi.
If you notice, translation from Japanese to Hindi has
happened prior to letter reaches on the Modi’s desk.
Now consider second scenario. Modi is travelling to Japan.
There is meeting of Modi and Abe. As we know Abe does not know Hindi and Modi have
no clue of Japanese. So during meeting there will be a translator, who will translate
Hindi to Japanese and vice versa in real time.
In this case, translation is happening in nearly real time.
Yash: Ok, I got
it. First scenario is Compilation while second is Interpretation.
Me: Fantastic.
Now my question is why Java has both compilation and interpretation?
Yash: This
easy. Java take benefit of compilation
by translating English into something intermediately language.
Me: This intermediate
language is called Byte Code.
Yash: Yep. Since
we have concept of virtual machine, each platform has its own virtual machine,
which acts as real time translator (interpreter), java become platform
independent.
Me: Excellent. We
will be discussing about Virtual Machine tomorrow.
No comments:
Post a Comment