r/programming • • Oct 21 '17

Using Java 9 Modularization to Ship Zero-Dependency Native Apps

https://steveperkins.com/using-java-9-modularization-to-ship-zero-dependency-native-apps#.Wes5IMWbUWE.reddit
310 Upvotes

109 comments sorted by

View all comments

29

u/mcguire Oct 21 '17
cli 21.7 MB

For comparison, the full JRE on this platform is 203 megabytes.

A “Hello World” CLI written in Go compiles to around 2 MB. 

As an aside, "hello world" in C or another true-native language using the system's standard C library is a few KB.

8

u/blobjim Oct 22 '17

Hello world in Java, excluding the VM, is around 400-500 bytes, and it can run on any platform with a JVM. The reason why hello world in native code is so small is because the interpreter is a piece of hardware (which probably has its own set of microcode) and comes with every computer. The JVM is just like a CPU, but is completely implemented in software, so of course it will take more space. If you had an operating system that ran Java code (like JavaOS was, I think?), then you have no JVM size overhead. It's really all about what you offload to where.