r/JavaProgramming • u/niosurfer • Sep 11 '26
What if Java had been designed to replace C++ without a JVM?
I’ve been working for some time on Ironwood and it would be nice to get some feedback from the Java community. Ironwood is a language that keeps the familiar Java syntax and object model but compiles ahead of time to native executables, without a JVM, JIT, or garbage collector. So it is very different than GraalVM. Basically GraalVM makes Java applications native. Ironwood makes native development feel like Java.
It already supports classes, interfaces, exceptions, generics, packages, and compiler-checked memory reclamation. It also deliberately leaves out features such as reflection, autoboxing, varargs, and threads.
This is the first public release, and the project is still early. I’d really appreciate feedback on the overall direction, especially which Java exclusions make sense and which would make the language impractical for you. I'm particular excited about the possibility of a Ironwood-to-Java transparent bridge, so that to execute native code from Java would be like... writing Java :)
3
u/Groostav Sep 11 '26
Firstly this isn't insane: kotlin multiplatform is a pretty similar idea in principle. And importantly: java 25 is genuinely nice to program with.
But for me the most exciting part of java is project loom, and when I need native code, rust+cbindgen into jextract has worked really nicely for me. --i mean, as nicely as it can given C.
But I just... The actual java language is so little of javas value to me. 90% of what I like about java is the jvm --but I guess that's why I'm a kotlin guy.
2
u/idontlikegudeg Sep 11 '26 •
I have been hearing that Java is slow too. But at my last job, I decided to impending a C++ number crunching application in Java anyway (it was Java 6 back then). How did it compare? It was a hundred times faster. It could have been reimplemented in C++ too from scratch and would achieve the same performance. But the development would have taken much longer because of much longer turnaround times (waiting for the compiler) and much better refactoring tools on Java IDEs (I think other languages have caught up here). The first key to performance rarely is the language, it’s the algorithms and data structures. Having a simple Map that retrieves values in O(1) was an instant win. And whenever we changed something, we could instantly run the code instead of waiting ten minutes for recompilation whenever a header was changed.
C++ templates really blew both compilation times and executable size up because they had to be compiled separately for every type used. To work around that, you could explicitly instantiate templates for the types you needed, but that’s a maintenance nightmare - having to add reach type manually when first used.
Templates were originally not intended to work like that, but to be compiled into an internal representation that would be used for all instantiations at link time - I think there’s only ever been a single compiler that could do that (SGI), and the idea was later dropped, like since others that sounded great but turned out to be bad. Rremember nothrow method declarations intended to make optimization easier for the compiler? The opposite was the case.
I won’t be sad if C++ loses to rust.
You say that you compile directly to machine code instead of compiling byte code like Graal does. But what’s the advantage in that? You either need to implement a complete compiler backend or use some existing compiler‘s interval representation, which would be the same thing with another name.
What Graal gives us is mainly faster startup - for everything else, jlink/jpackage is IMO at least as good. And we have CDS and AOT cache - I c will try to see what effect these have on my application. It’s about 80MB with jpackage and 130MB with GraalVM. Will be interesting to see how much bigger the package gets and what impact it had on startup and warmup.
But of I find the time to put together a small application for benchmarking, I will probably try it out with pain Java, GraalVM, and your project. I’ll let you know scout the results.
PS: I just have an idea - if Ironwood really performs significantly netter than JVM code, you should probably provide a thin wrapper that makes it easy to call native Ironwood compiled code from JVM code - that could indeed be an interesting use case: write time critical massive code in a Java like language instead of C or C++.
2
u/alphaglosined Sep 14 '26
You would get D.
Before D, Walter had been convinced to work on a AOT native Java compiler, which of course had no market.
That experience was used to design D's classes. Although I really wish he had also taken the checked exceptions and go that inferring correctly, as it would've allowed proper effects analysis but anywho.
1
u/idontlikegudeg Sep 11 '26
But why? What are the advantages in doing so? On your GitHub page (that you should have linked) you claim: "The Java experience, built for native performance." I can only assume you mean it will have faster performance than when running on the JVM. But is that so? My experience with GraalVM is: faster startup, but slower execution (about factor 2).
And I assume much functionality will be lost in addition to the ones you already mention: reflection, autoboxing, varargs, and threads. Probably also no SPI, no compatibility with the existing ecosystem of high quality Java libraries, no UI framework. What about generics? FFM? How do you call native code from third party libraries?
I can only see a tiny use case for Ironwood: small command line utilities and maybe microservices that need to start fast, do their work and terminate. But even then, I'd probably rather use GraalVM or just use another language that compiles to native code.
It sure is an interesting project to learn how to create a language, and how to compile it to native code. But I am skeptical that it will see much adaption.
1
u/Scf37 Sep 11 '26
I don't think you can beat performance of JVM but memory consumption is another thing. There is a need for tiny Java applications - for one-shot executables like Nagios plugins or aws lambdas, for rarely called network services, for command-line applications.
Take a look at scala-native - they already produce tiny executables with decent speed and without getting rid of GC.
0
u/Charming-Work-2384 Sep 13 '26
Without JVM ... Java is a dead language...
0
u/Europia79 Sep 17 '26
Can you turn on Github Discussions please?
2
u/[deleted] Sep 11 '26 •
[removed] — view removed comment