Last active
April 8, 2018 20:43
-
-
Save zealfire/36a422b71f4654407c0098a1dd2877a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://patshaughnessy.net/2012/2/15/is-ruby-interpreted-or-compiled | |
Main difference between JIT and JVM is that, JIT is part of JVM itself and used to improve performance of JVM. JIT stands for Just In time compilation and JVM stands for Java Virtual Machine. JVM is a virtual machine used in Java programming platform to execute or run Java programs. Main advantage of JVM is that, it makes Java platform independent by executing byte codes. Java source code is compiled into class files, which contains byte code. These byte codes are then executed by JVM. Now here comes JIT. Since execution of byte code is slower than execution of machine language code, because JVM first needs to translate byte code into machine language code. JIT helps JVM here by compiling currently executing byte code into machine language. JIT also offers caching of compiled code which result in improved performance of JVM. by the way difference between JVM and JIT is also a good Java interview question to ask. Well, this is just a simple explanation, JIT is lot more complex than this. There are sophisticated algorithm which helps JIT to pick most executed code for compiling into machine code. | |
JVM vs JIT | |
Here are couple of more differences between JVM and JIT in Javaprograming platform : | |
1) Main difference between JVM and JIT is there purpose, main goal of JVM is to provide platform independence while objective of JIT is to improve performance of JVM, by compiling more code into machine language. Just keep in mind that this compilation also takes time, so translating all code into native code is not worth doing. That's why JIT mostly compile frequently used code into native code. | |
3) Another difference between JIT and JVM is that, JIT is part of JVM. One example of JIT is Oracle's Hotspot JIT which comes with Hotspot JVM. | |
2) At last, JVM is older concept than JIT. JIT actually get invented to improve performance of JVM. | |
That's all on difference between JVM and JIT in Java. As I said, JIT is part of JVM and used to improve JVM performance by dynamically compiling or translating Java byte codes into native machine language code during execution time. | |
1.Is Java compiled or interpreted language? | |
Posted on August 31, 2014 by siddarth | |
Firstly let us know the difference between the compiled and interpreted language. | |
Interpreted Language | |
Example: JavaScript | |
Consider we are executing a file with name “add.js”. To run this file. This file is given to a software called Interpreter. | |
Interpreter does the following. | |
Read the first line of add.js. | |
Convert the first line of add.js to binary. Now execute this binary. | |
Read the second line of add.js. | |
Convert the second line of add.js to binary. Now execute this binary. | |
Like wise do the same thing till the last line of the program. | |
So read a line of the program. Convert the line to binary. | |
Then without storing the binary somewhere, execute the binary immediately. | |
The programming language which requires an interpreter to execute. That programming language is called an interpreted language. | |
Compiled Language | |
Example: C, C++. | |
Consider we are executing a file with name “add.c”. To run this file. This file is given to a software called Compiler. | |
Compiler does the following. | |
Create a file with name “add.o”. | |
Read the first line of “add.c” and convert this line to binary. Store this binary in “add.o”. | |
Read the second line of “add.c” and convert this line to binary. Store this binary in “add.o”. | |
Like wise do the same thing till the last line of the program. | |
This “add.o” is called the object file. It contains the binary code of each line in “add.c”. | |
Now first line of “add.o” is executed. | |
Then second line of “add.o” is executed. | |
Like wise the last line of “add.o” will be executed. | |
So read a line of the program. Convert the line to binary. Store the binary somewhere. Continue this process till the last line of the program.Then execute each binary line by line. | |
The programming language which requires a compiler to execute. That programming language is called a compiled language. | |
Java is both compiled and interpreted language | |
Consider we are executing a file with name “add.java”. To run this file. This file is given to a software called javac. | |
javac does the following. | |
Create a file called “add.class”. | |
Read the first line of “add.java”. Convert this line to byte code. Store this byte code in “add.class”. | |
Read the second line of “add.java”. Convert this line to byte code. Store this byte code in “add.class”. | |
Like wise do the same thing till the last line of the program. | |
So read a line of the program. Convert the line to byte code. Store the byte code somewhere. Continue this process till the last line of the program. This is nothing but compilation. | |
“add.class” file contains the byte code of each line in “add.java”. | |
The file “add.class” is given to a software called JVM. JVM is an interpreter. | |
JVM reads the first line of “add.class”. Convert this line to binary. Then execute this line. | |
JVM reads the second line of “add.class”. Convert this line to binary. Then execute this line. | |
Like wise do the same thing till the last line of the program. | |
Byte code is not the binary code. It is not a java code. It is an intermediate code. Java requires a compiler to convert java code to byte code. | |
Java requires an interpreter(JVM) to execute the byte code. So java is both compiled and interpreted language. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment