Are there Java compilers that allow the compiled code to be run from an existing operating system. IE compile source on linux run only on linux after compilation. This is mostly a speed question but if anyone can add pros or cons of this that would be great.
In most cases you can only loose.
The Java concept involves the JIT compiler that does exactly what you
are describing, but on each run of the JVM. So the only thing you can
save is the time for the JIT. You will agree, that this is always a O(1)
Problem regarding one application, adding some constant time to an
application run.
But on the other side there are several drawbacks.
First of all Linux is not Linux. There are different CPUs, different
ABIs and so on. So if you compile for a target platform, it must either
use the common denominator of a set of platforms or be specific to
exactly one existing machine with exactly one kernel and so on.
Taking the common denominator of let's say linux ELF on x64 leaves
different CPU features like AVX unused around.
Compiling for exactly one platform on the other side may result in code
that will no longer run after slight changes, like new hardware or
something like that.
So what are the benefits of precompiled byte code? Nu rule forbids
caching of the JIT results by the JVM. So the benefit of precompiled
code could be combined with the benefits of JIT. But as long as the time
taken for JIT compilation is comparably small even that makes no sense.
Marcel