Re:Compiling Java into Native Binaries with Graal and Mill
by killingtime74 on Sunday February 02, 2025 @01:09AM
(#42906385)
We've been using it at work for a few years. A cli tool, builds in about 6 minutes. We compile it to Linux, Mac ARM and Mac Intel. You're correct about configuring libraries but I found those to be the minority. Most work without configuration. I do this because I will not use Golang if given a choice and Rust is not allowed.
[ Parent
| on HN ]
Re:Compiling Java into Native Binaries with Graal and Mill
by Jabihjo on Sunday February 02, 2025 @04:48AM
(#42907551)
What's your issue with Golang? (Not hating, just curious)
Re:Compiling Java into Native Binaries with Graal and Mill
by killingtime74 on Sunday February 02, 2025 @05:25PM
(#42912487)
(sorry it's probably it an unpopular opinion) the error handling is hard to read, they purposely didn't incorporate any syntax sugars and innovations of previous years. They were one of the first popular languages with go routines although Project Loom in Java will soon have preemptive multi threading as well.
Re:Compiling Java into Native Binaries with Graal and Mill
by pjmlp on Tuesday February 04, 2025 @05:54AM
(#42930819)
I am on the same boat, JVM, .NET and nodejs ecosystems before Go.
So many languages, tools and libraries to chose from, without the "simple minds" culture, even C manages to be more feature rich.
Re:Compiling Java into Native Binaries with Graal and Mill
by sgammon on Tuesday February 04, 2025 @06:12AM
(#42930935)
Builds have been slow for a long time via Native Image, but make sure you upgrade to the latest because it has gotten much faster lately. They've also worked hard on binary size.
A pure Java hello world now compiles in a few seconds on a commodity machine and weighs in at about 9mb.
Also, make sure you enable `-Ob` on newer versions of GraalVM, which significantly speeds up build times.
Re:Compiling Java into Native Binaries with Graal and Mill
by gf000 on Wednesday February 05, 2025 @10:46AM
(#42950164)
I would only use -Ob for development, it's not for production builds.
Re:Compiling Java into Native Binaries with Graal and Mill
by nomercy400 on Tuesday February 04, 2025 @06:12AM
(#42930937)
How do you compile to multiple platforms? Do you have separate machines for each platform?
Do you use any cli library in front? Is 12-20mb acceptable for a cli executable?
Working on a cli tool poc for work here, hence the interest.
Re:Compiling Java into Native Binaries with Graal and Mill
by sgammon on Tuesday February 04, 2025 @06:13AM
(#42930947)
Sorry, I know you weren't asking me, but for this same use case, yes, I've used a GHA build matrix with each OS/arch pair.
Cosmo/APE support would fix this, and GraalVM already ships with a Musl libc implementation, so it isn't very far off.
Re:Compiling Java into Native Binaries with Graal and Mill
by killingtime74 on Tuesday February 04, 2025 @03:09PM
(#42937898)
Like the other poster, we have to compile it separately on different architecture machines (we are on Bitbucket). We use Quarkus as the base and picocli as the cli https://quarkus.io/guides/picocli. Quarkus takes care of a lot and makes the native image experience nicer. Size wise, for internal use our users don't complain, since we are all devs.
I think you can shrink the size with one of the optimisation levels https://www.graalvm.org/latest/reference-manual/native-image...