Hacker News new | ask | show | jobs
by pritambarhate 1228 days ago
Java had AoT compilers for more than 20 years, https://en.wikipedia.org/wiki/Excelsior_JET

If Google really wanted they could have wrote one.

2 comments

The fact that Excelsior is dead probably says something.

There are AoT compilers for Java, but I'm not aware of any successful widely-used ones. Java and the Java ecosystem rely pretty heavily on class loaders and reflection which make AoT compilation very difficult. Java in its bones is designed to be a JIT VM language and you'll always be going against the grain if you try to statically compile it.

Dart was also initially designed to be a JIT VM language (by the same folks who made the HotSpot JVM) but without many of the pitfalls in Java that make AoT hard, and over time we have deliberately evolved the language (in breaking ways!) to make it much more amenable to static compilation.

Languages are not all interchangeable and some languages are better suited for certain implementation strategies than others.

GraalVM native is quite a big thing nowadays, and reflection is not really a problem for AOT, class loading is more so, but that is easily solvable by assuming a closed world (the way Graal does it). So you just simply list all the classes you plan to reflect on/load and that’s it.

> Languages are not all interchangeable and some languages are better suited for certain implementation strategies than others

Sure, but I don’t claim to replace SQL or Prolog with Java, but a regular old managed language which has zero unique features that would give it a reason to exist.

> If Google really wanted they could have wrote one.

Which they did, but for Dart instead.

Which has zero ecosystem and just reinventing the wheel.
> More importantly, it was a Google language that they could mold for their own needs, not so possible if it's an outside language like TypeScript. For example, early on, they asked the Dart team to create an AOT compiler since Apple does not allow JITted code apparently (not sure how React Native gets around this then), or maybe it didn't back then, and the Dart team was able to do it successfully for the Flutter team. Try asking the TypeScript team to do the same, it's next to impossible.

Replace TypeScript with Java above.

Why would you need to modify the language? Dart is the most basic managed language without any novel feature. There is zero reason why, say, java couldn’t have been fitted for this particular niche.
How will you convince the Java team to add things you want to make it work better for your framework? You could try adding them yourself but you'd be forking and making your own Java dialect at that point. They did that instead with Dart which they own.
What would you need for a framework that can’t be implemented as a library? Will we recreate every language from scratch for the next logging, gui lib, web framework as well?