[OSM-talk] Java and JOSM
hartmut at php.net
Mon Apr 12 15:05:24 UTC 2021
On 12.04.21 16:22, Marc Gemis wrote:
> Java is not a purely interpreted language, it uses a Just-in-time
> compilation. 
well, Java the language is actually compiled. It is just being compiled
into a low level intermediate language, the JVM bytecodes.
It is then up to the runtime engine whether it further converts the JVM
bytecodes into actual machine code for the CPU it is running on, or
processes the byte codes directly in a small interpreter runtime. JVMs
usually do the former, while e.g. PHP did the later and has only recently
started to change this with PHP 8.
But even when converting JVM byte codes into native code, you have a
tradeoff between compile time and run time. For code that's only going
to be run once you may be better off just interpreting the byte codes
directly, or compiling them into actual machine code at the lowest
optimization level. For code that runs repeatedly, like the main event
loop of a GUI app, on the other hand it makes sense to spend more time
on optimization of the generated native machine code.
And that's what JVMs usually do: gradually increase the optimization
of machine code for parts of the code that are being run often, by
re-compiling JVM byte code when execution statistics show that it seems
to be worth the effort.
PS: The good old interpreter vs. compiler distinction is a dead horse
anyway. All but the most simple DSLs these days are either true
compilers, or hybrids that lean more towards the compiler side of
things. The last true interpreter that I remember using was PHP 3,
More information about the talk