Live data from Hacker News

H2JVM – A Haskell Library for Writing JVM Bytecode

discourse.haskell.org

1–10 of 17 posts

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#2
At a quick glance, it seems to be missing some hook to resolve class hierarchies - which is needed when merging stacks with different types. Consider

    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...

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#3
This... Confuses me profoundly. My entire career I've worked with Java, and it's mostly a pretty decent language, imo. I think my biggest gripe with Java is the JVM. It's limiting, doesn't really provide any value(the proposed value is portability, but we always run apps in docker containers anyway, so what is it really doing for us?)

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?

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#5
post #3

This... Confuses me profoundly. My entire career I've worked with Java, and it's mostly a pretty decent language, imo. I think my biggest gripe with Java is the JVM. It's limiting, doesn't really provide any value(the proposed value is portability, but we always run apps in docker containers anyway, so what is it really doing for us?) I (kinda) get why someone might want to write Haskell rather than Java, but I'm jus…

Pretty good performance for low effort is a big win.

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#6
post #3

This... Confuses me profoundly. My entire career I've worked with Java, and it's mostly a pretty decent language, imo. I think my biggest gripe with Java is the JVM. It's limiting, doesn't really provide any value(the proposed value is portability, but we always run apps in docker containers anyway, so what is it really doing for us?) I (kinda) get why someone might want to write Haskell rather than Java, but I'm jus…

An interesting take.

You get lots of things for free when targeting JVM bytecode. GCs, JITs, interop with one of the largest and most battle tested ecosystems.

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#7

see also https://github.com/Frege/frege and https://github.com/mchav/froid (though both are kind of dead I guess?)

There is also Idris 2 for JVM (https://github.com/mmhelloworld/idris-jvm)

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.

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#8
post #3

This... Confuses me profoundly. My entire career I've worked with Java, and it's mostly a pretty decent language, imo. I think my biggest gripe with Java is the JVM. It's limiting, doesn't really provide any value(the proposed value is portability, but we always run apps in docker containers anyway, so what is it really doing for us?) I (kinda) get why someone might want to write Haskell rather than Java, but I'm jus…

[deleted]

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#9
post #3

This... Confuses me profoundly. My entire career I've worked with Java, and it's mostly a pretty decent language, imo. I think my biggest gripe with Java is the JVM. It's limiting, doesn't really provide any value(the proposed value is portability, but we always run apps in docker containers anyway, so what is it really doing for us?) I (kinda) get why someone might want to write Haskell rather than Java, but I'm jus…

The reason most "serious" or important software is written for the JVM these days is because it gives you an unparalleled combination of performance, productivity, and observability. There's almost no competition if these things are what you need. The problem isn't so much why pick Java among the alternatives, but that there are hardly any alternatives.

Re: H2JVM – A Haskell Library for Writing JVM Bytecode

#10
post #3

This... Confuses me profoundly. My entire career I've worked with Java, and it's mostly a pretty decent language, imo. I think my biggest gripe with Java is the JVM. It's limiting, doesn't really provide any value(the proposed value is portability, but we always run apps in docker containers anyway, so what is it really doing for us?) I (kinda) get why someone might want to write Haskell rather than Java, but I'm jus…

This project isn't for running Haskell on the JVM, it's for writing a compiler that produces JVM bytecode. You'd use it if you wanted to implement your own JVM language in Haskell or maybe if you wanted to have some kind of JVM-backed domain-specific language embedded in Haskell.
Post reply on HN