H2JVM – A Haskell Library for Writing JVM Bytecode
Posted by rowbin 2 days ago
Comments
Comment by J-Kuhn 17 hours ago
var foo = expr ? new Foo() : new Bar();
For such an expression, some superclass or superinterface for both Foo and Bar has to be chosen.What I am curios about is, if the java classfile API[1] provides a good model that could work in Haskell as well - I always had the impression that it was heavily influenced by functional programming, for example it uses "lifting transforms"[2].
PS: Good work on the label resolving part - this model is also used by the Java Classfile API and before it, ASM.
[1]: https://docs.oracle.com/en/java/javase/26/docs/api/java.base... [2]: https://docs.oracle.com/en/java/javase/26/docs/api/java.base...
Comment by amarant 17 hours ago
I (kinda) get why someone might want to write Haskell rather than Java, but I'm just not sure why you would want to run Haskell on the JVM?
Comment by cogman10 15 hours ago
Java is an ok language, but what really makes it shine is the JVM. It's one of the fastest VMs out there and is one of the most customizable ones as well. For example, pretty much all other languages with a GC have just a GC and that's it. Java allows you to pick and choose your GC based on the workload.
It is one of the least limiting VMs out there because any knob you might want to tune, can be tuned. It's a huge value add.
I think the only part of the JVM that's not great is the fact that objects are bulky and the lack of value classes. Which ultimately means every struct like object you want can have a pretty hefty price in terms of memory. But otherwise, it's best in class basically for everything.
Comment by tikhonj 17 hours ago
Comment by pron 17 hours ago
Comment by AlotOfReading 14 hours ago
I don't think there's any single language that most serious software is written in.
Comment by pron 14 hours ago
Comment by vips7L 17 hours ago
You get lots of things for free when targeting JVM bytecode. GCs, JITs, interop with one of the largest and most battle tested ecosystems.
Comment by rienbdj 17 hours ago
Comment by internet_points 17 hours ago
Comment by J-Kuhn 17 hours ago
Frege targets Java source code, which is then compiled by javac - the downside of that approach is you can not preserve the line numbers for debug information.