← Fri, Oct 2 digest

Turbo Haskell

read article ↗ hn thread ↗

Edward Kmett created Turbo Haskell (THC), a JIT/AOT compiler that runs GHC Core on the JVM using Truffle and GraalVM.

summary is enough The project is a high-effort technical feat, but the article is a brief announcement of a prototype rather than a deep dive.

summary

Turbo Haskell (THC) leverages GHC for parsing and optimization, then uses Truffle and GraalVM to execute GHC Core on the JVM. It supports GHC 9.14.1 prim-ops, polyglot FFI for languages like Python and Ruby, and implements a custom tail-call optimization strategy to avoid JVM stack overflows. The project can JIT or AOT compile complex programs, including GHC itself, with performance currently hovering around 10-20% slower than GHC.

key points

  1. Uses Truffle and GraalVM to provide a JIT for GHC Core on the JVM.
  2. Implements a custom tail-call mechanism using Bloom filters and code transformation to avoid traditional trampolining.
  3. Provides zero-copy UTF-8 string conversion between Haskell's Data.Text and other polyglot languages via GraalVM.
  4. Supports GHC-style green threading using Project Loom.

who should read it

Haskell developers and JVM engineers interested in language interoperability and JIT compilation.

discussion positive

consensus

The project is viewed as an impressive technical achievement by those familiar with the author's reputation, though some question the utility of Haskell on the JVM.

pushback

One commenter accused the project of being 'slop' generated by an AI agent due to the high commit frequency, which was strongly refuted by other users.

best comment by edwardkmett ↗

Java FFI can be done, it is just on the messier end of the spectrum. I do a little bit of it as needed, but I've focused in on Polyglot languages for now, and deferred a lot of the hooks for nicely handling it to later work.

Talking about Java FFI invites you to say 'well then smart-ass how do you extend this Java class/interface over here with code written in your language' and frankly, that has never had a satisfying answer for any language that isn't Java.

But today you can pass Haskell Data.Text out through the FFI binding framework and it shows up on the other side as a valid …

The author clarifies the technical nuances of Java FFI and the zero-copy semantics of TruffleStrings.

Generated by an LLM from the article and thread. Check the sources before relying on it.