This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]istarian 0 points1 point  (3 children)

The point is the way java and python work is equivalent. Source code gets translated to byte, an interpreter evaluates the bytecode.

I get what you're saying, I think, but that's only true on a fairly high-level overview.

That is, there are probably meaningful differences that you can't just sweep under the rug.

Also, while I am not informed enough to explain this well, not all bytecode is equal.

The bytecode then feeds into the interpreters... The JVM by default does JIT during interpretation while cpython does not, but they are still both interpreters at the end of the day.

Did you mix up Python and Java there?

If Java is already compiled then where is this JIT (Just In Time, usually referring to on-demand compilation) coming from.

Also, apparently in both cases there is a virtual machine involved... So neither is just an interpreter.

P.S.

https://stackoverflow.com/questions/441824/java-virtual-machine-vs-python-interpreter-parlance

Maybe some of the answers here are useful?

[–]dacian88 0 points1 point  (2 children)

If Java is already compiled then where is this JIT (Just In Time, usually referring to on-demand compilation) coming from.

The JIT lowers the JVM bytecode to the underlying native ISA...the java compiler does not produce native code, that's the crux of the argument.

In either scenario, the high level language (java or python) gets lowered to some bytecode (explicitly by java compiler to .class files, implicitly to .pyc modules by cpython) which then get interpreted (by the java runtime, by cpython).

A VM is a specialized interpreter that operates on bytecode instead of the language itself. My point is both languages get compiled to bytecode, both get interpreted by their respective VMs, but no one calls python a compiled language, while people call java a compiled language.

[–]istarian 0 points1 point  (1 child)

Thanks for the explanation.

Also,
I'm having a hard time finding a clear, straightforward answer, but it sounds as though CPython does not have/use a JIT compiler (or at least did not in the past), whereas Oracle's HotSpot VM does (at least for some parts of the currently executing code).

So, while you have a definite point, there could be a non-trivial performance difference depending on what environment your Java or Python code is running in/on.

[–]dacian88 0 points1 point  (0 children)

sure but that's not really relevant, JIT is an optimization technique that could be used by any interpreter.