blog/aot-vs-jit-compilation-in-java #52
Replies: 8 comments 4 replies
-
Thanks for this great blog post. I just pin it as a great resource for my students. |
Beta Was this translation helpful? Give feedback.
-
I think it's one of the best explanations about JIT & AOT I've found on the Internet. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the great article. |
Beta Was this translation helpful? Give feedback.
-
My question: so I tried to google and read about it for a bit but i still couldn't find an answer, maybe it's cause i'm new to java and just beginning to learn so i might not have been able to fully understand what i was reading, so here's my question. What's the purpose of the JVM? why was this program created to run java programs? Feel free to point out everywhere i'm wrong but here i go. So for a lot of languages u can just create a compiler for it and have the source code compiled into machine code (for the system ur working on if u want). I believe that's what C and C++ do, they just compile their source code into machine code (or maybe assembly code) and then it gets executed by the operating system. This is a pretty fast and effiecent way to run a program and u will end up with some executable file that u can run at anytime and never have to recompile since it's pretty much machine code to run the program. It sounds pretty simple and an efficent solution, unless i'm missing lots of details that i'm not knowledgable about. Sure u can say that compiled code is platform dependent but what's wrong with that, the code itself is platform independent i believe and u could just pass the source code around to different computer systems, and have specific compilers for each system that u could download to compile the code for u just once and then ur good...never again...i think. Now you have java, which goes to the lengths of first compiling the source code to bytecode and then having some virtual machine interpret this code to machine code and execute it with the O/S, while at the same time also doing JIT on the code to increase performance. How is this better than the orginial method that was used that i mentioned above. To me it seems like just extra work. Sure people say bytecode is write once read anywhere, but u still need to create differnt jvm's for each system in order to run and execute the bytecode. First u have to compile it to bytecode, then u have to interpret it and JIT the bytecode as well. In the end you put the program together and pass it around, u usually put it inside some jar file and probably do other things to make this program available to the public who have to download the application then they can run it by double clicking it which will essentially have to start up a jvm instance and interpret and JIT all the code again (since they're just a bunch of class files stored in a jar file). meanwhile with the C or c++ program, it's already compiled into machine code so it can run way faster i believe. I'm hoping u can tell me what and where i'm wrong, what benefits does the jvm give u that make it worth using bytcode and JIT instead of just normal old compiling. to me it seems like it would be much better to use the original method cause of greater speed. I've read that the JVM does a lot of extra work taking care of all sorts of things when it's executing, but isn't that something a normal compiler can be programmed to handle as well when compiling to machine cod and in return it would do it only once instead of everytime u run the program in the case of java. Does the jvm even save previous cached JIT compilations to reuse and save them when re-executing a program or does it just start all over for the bytecode? lastly what is ahead of time compilation? is it the same thing as when a C or C++ program compile to machine code or is it a term specifically for jvm's, sort of like a counter to JIT? does it only apply for intermediate code like bytecode? |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for the article but I got a question. Why does the JIT has higher throughput? The article mentioned:
So there's no such technique in AOT and I guess and that makes the difference? Also, is there any other reference that dive into this topic? |
Beta Was this translation helpful? Give feedback.
-
Hi @LinzeSu,
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the great post. |
Beta Was this translation helpful? Give feedback.
-
Hi Cesar! Thanks for the great post. I think there is mistake in figure 1. Java compiler is also platform dependent. However, the output, Java bytecode, is platform independent. My suggestion is that you should show the outputs, bytecode and machine code as platform independent and dependent respectively. |
Beta Was this translation helpful? Give feedback.
-
blog/aot-vs-jit-compilation-in-java
AOT compilation, supported by the GraalVM compiler, seems to be the future for Java and the programming languages that compile to JVM bytecode. But what is the difference between compiling source code using a JIT compiler w.r.t using an AOT compiler? This post explains the difference between these two approaches.
https://www.cesarsotovalero.net/blog/aot-vs-jit-compilation-in-java.html
Beta Was this translation helpful? Give feedback.
All reactions