5 ms·
Java is not statically compiles to machine code. It’s statically compiles to byte code which is hen interpreted or dynamically compiles to machine code. So to
by diroussel 8y ago
Java is not statically compiles to machine code. It’s statically compiles to byte code which is hen interpreted or dynamically compiles to machine code.
So to way java is statically compiles is not quite correct in my opinion.
- pjmlp 8y agoIf you are talking about free Java compilers that is correct. Most commercial compilers, specially those for embedded markets always had AOT native code as deployment option. But now the bad Oracle is finally making the AOT compiler research they got from Sun Labs available for free.
- nadioca 8y agoHow does it compare against c/c++ in terms of performance ?
- pjmlp 8y agoOf course it is a bit slower, as Java does not take advantage of UB nor disabling security checks for the ultimate performance. And depending on the use case there is always the issue of value vs reference types. But it is good enough for most use cases of typical desktop software, to the point of Oracle's long term roadmap is to rewrite the remaining C++ parts of OpenJDK in Java (Project Metropolis), using a subset they are designing called System Java. Also can check Android flagship devices (better for performance comparison), since Android 5.0, Java is also AOT compiled to native code. Although Android 7 changes it to a mix of interpreter written in Assembly, JIT and AOT with PGO. And Android P will introduce sharing of PGO metadata across devices via Play Store.
- stefs 8y agothe native executables native-image generates are usually a bit slower than hot-spot JIT'ed code (~10% on average according to one article). they do need much less RAM and startup time is _a lot_ lower though. here it is: "Right now peak performance is a bit worse than HotSpot, but we don’t want to advertise that (and we want to fix it of course)." http://www.graalvm.org/docs/reference-manual/aot-compilation/ http://www.graalvm.org/docs/reference-manual/aot-compilation...
- msla 8y agoAt least one free Java compiler compiles to machine code: gcj. https://gcc.gnu.org/wiki/GCJ https://gcc.gnu.org/wiki/GCJ
- pjmlp 8y agoYes, but it sadly died around 2009 when most developers left the project. GCC devs just kept it around because of the unit tests, but with GCC 7 they removed it from the distribution.