r/JavaProgramming • • 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 Upvotes

17 comments sorted by

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/niosurfer Sep 11 '26 edited Sep 11 '26

Thanks for your nice feedback.

Firstly this isn't insane: kotlin multiplatform is a pretty similar idea in principle.

I'm aware of Kotlin/Native, but I'm a Java guy for 30 years now. I hear great of Kotlin and Scala, but at this point unfortunately my brain has refused to learn a foreign language and it favors OOP over FP :|

And importantly: java 25 is genuinely nice to program with.

Any feature in particular? I came from C/C++ and Java is a joy. But that's my personal experience.

But for me the most exciting part of java is project loom

I can see that, specially when you are a Kotlin guy. My personal experience is not that I dislike threads. It is just that threads are a bug factory. I prefer non-blocking event-loops through selectors.

rust+cbindgen into jextract

Unfortunately my brain cannot do Rust :|

I'm a JIT guy. For long running applications I still think the JIT wins and it is convenient for everyone: for the developer and for the optimizer. But after 30 years (serious) hearing that Java is slow and C++/C (and now Rust) is faster, I have always wanted to do Ironwood.

2

u/idontlikegudeg Sep 11 '26 • Heartwarming

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/niosurfer Sep 11 '26 edited Sep 11 '26

I won’t be sad if C++ loses to rust.

Me neither :)

You say that you compile directly to machine code instead of compiling byte code like Graal does. But what’s the advantage in that?

I byte code is need for a VM to interpret. When going straight to machine code I don't need to pass through byte code first. Because Ironwood is a subset of Java, compiling arbitrary byte code would not work because it would contain several dynamic Java features that Ironwood do not support on purpose, for example reflection.

If Ironwood really performs significantly better than JVM code

30% faster than Java for a price-time priority matching engine. The details are here.

I just have an idea, 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++.

Yeah, you did not read the post until the end :)

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 :)

This is coming soon. You can click here for the full story.

2

u/alphaglosined Sep 14 '26

What if Java had been designed to replace C++ without a JVM?

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.

2

u/niosurfer Sep 14 '26

D Programming Language: What if we redesigned C++ into a cleaner, more powerful modern systems language?

Ironwood Programming Language: What if Java had originally been designed to compile directly to native code, without a JVM or garbage collector?

Ironwood and D are both AOT compiled native languages, but D is a feature rich systems language closer to C++, with raw pointers, garbage collection, and powerful metaprogramming. Ironwood is deliberately simpler and more Java like, aiming to give Java developers native performance and explicit memory control without a JVM, garbage collector, raw pointers, or ownership-based programming.

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.

2

u/niosurfer Sep 11 '26

Thanks for your feedback.

But why?

After 30 years (serious) hearing that Java is slow and C++/C (and now Rust) is faster, I have always wanted to do Ironwood :)

I can only assume you mean it will have faster performance than when running on the JVM. But is that so?

I'm a JIT guy. For long running applications I still think the JIT wins in performance, convenience and everything else. Which sounds like a contraction for why would I do Ironwood. It is just a different way to do Java. I'm definitely not claiming that anyone should abandon the JVM, but there is also a use-case for everything. Before Ironwood I don't think Java programmers had the Ironwood option.

My experience with GraalVM is: faster startup, but slower execution (about factor 2).

I have the exact same experience. And a factor of two is huge. But Ironwood is very different than GraalVM or RoboVM. Ironwood compiles Java source code. GraalVM and RoboVM compile Java bytecode. GraalVM makes Java applications native. Ironwood makes native development feel like Java.

What about generics?

Generics is fully supported. And better than Java because you can have ArrayList<int>. Check here for the full list.

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. FFM? How do you call native code from third party libraries?

Most of this stuff, besides reflection and other dynamic things incompatible with a closed-world compiler, can be implemented. I just think it is prudent to start small and grow slowly with feedback from the community.

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.

2

u/niosurfer Sep 11 '26

I don't think you can beat performance of JVM

I'm a JIT guy. For long running applications I still think the JIT wins and it is convenient for everyone: for the developer and for the optimizer. But after 30 years (serious) hearing that Java is slow and C++/C (and now Rust) is faster, I have always wanted to do Ironwood.

1

u/InstantCoder Sep 12 '26

I’ve played around with Java by starting a native webserver and listening to requests and than running it from the source file with just: java filename.

And surprisingly, it started up in around 10ms on my machine.

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 • Regret

[removed] — view removed comment

1

u/niosurfer Sep 11 '26

Am I too late for the party? 🤣