from Hacker News

Compiling Java into native binaries with Graal and Mill

by lihaoyi on 2/2/25, 1:40 AM with 99 comments

  • by wiradikusuma on 2/2/25, 5:06 AM

    "Almost every Java program, library, and framework uses some degree of reflection and dynamic classloading, and so you do have to spend the effort to configure Graal appropriately." -- this is by far the biggest problem with native binary compilation.

    Imagine spending 15+ minutes building an exe, and it stopping at minute 15 because some things needed to be added in the config. Or, after waiting 30 minutes to have the exe ready, it refused to run because of the same problem.

    The issue is we don't know what we don't know. You don't "forget to include something" because you don't know what to include (and even after seeing the error, you still don't lol).

    I just wished all 3rd party libraries put their "include this config to include my lib in your exe", just like OSGi manifest (https://www.ibm.com/docs/en/wasdtfe?topic=overview-osgi-bund...).

    For example, an issue still open for almost 2 years: https://github.com/firebase/firebase-admin-java/issues/800

  • by p2detar on 2/1/25, 10:54 AM

    > Graal can only create native binaries targeting the system on which it is running. That means that if you want to create binaries for {Linux,Windows,Mac}x{Intel,ARM}, you need 6 different machines in order to build the 6 binaries and somehow aggregate them together for publication or deployment. This is not a blocker, but can definitely be inconvenient v.s. some other toolchains which allow you to build native binaries for all targets on a single machine.

    To me this is a huge downside. One of the reasons I like Go so much is that I can build binaries for any platform I want to support on my Mac or with Docker.

  • by dkjaudyeqooe on 2/4/25, 9:00 AM

    I'm under the impression that the Community Edition version of GraalVM is neutered by a limited garbage collector and some other limitations when producing native binaries.

    Anyone know if this true?

  • by theflyinghorse on 2/2/25, 4:56 AM

    Mill looks like an interesting option to try all around.
  • by neonsunset on 2/4/25, 8:10 AM

      dotnet publish /p:PublishAot=true
    
    :)
  • by neuroelectron on 2/4/25, 9:12 AM

    Java had a huge reflection exploit a long time ago and most places blacklisted that library as a result so not a big loss there.