Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thanks for the detailed response. I am currently learning C++, so am not aware of the DLL concept. However, everything else makes sense to me. Commented Jan 4, 2019 at 16:41
  • 1
    This is a much better answer but I think though that the distinction between interpreted and JIT isn't as cut-and-dried as it seems from this answer (the wiki link does provide more nuance.) The main benefit of JIT isn't loading and unloading. The big benefit of JIT is the ability to apply optimizations at runtime based on empirical data from actual execution. A section of code that was compiled to machine instructions might be rewritten many times based on how it's used. JIT also allows for things like stack allocation even though Java doesn't provide any direct mechanism for that. Commented Jan 4, 2019 at 18:09
  • @JimmyJames: In HotSpot in particular, the main benefit of JIT is the ability to deoptimize. You can make compiler optimizations even if you cannot prove that they are correct, and then simply throw away the code and fall back on interpretation in case your optimizations were wrong. For example, escape analysis is equivalent to solving the halting problem, so you can't know whether values will escape or not, but you can simply stack-allocate values anyway under the assumption that they won't escape, and when they do, you just re-allocate on the heap. Commented Jan 9, 2019 at 16:54
  • @JörgWMittag That doesn't really make much sense to me. In order to believe that, we'd have to think that initial optimization is only done to allow for more deoptimizing. "so you can't know whether values will escape or not", I'm not so sure about that. I can look at code and point to values that never escape. There are cases where it's not provable and a more aggressive optimizer can try that which comes back point of deoptimization: to allow for more aggresive optimization i.e. it's part of optimization, not the other way around. Commented Jan 9, 2019 at 17:12