Turbo Haskell
A week ago, I initiated the development of THC, a project I dubbed the "Turbo Haskell compiler." This compiler was born during a vacation visit to Bartosz Milewski. Currently, THC boasts support for every GHC 9.14.1 prim-op and includes a JIT for GHC Core, enabling Haskell execution on the JVM.
Threading is no issue for THC, as it leverages the same approach I outlined in Cadenza, employing Truffle and GraalVM. While the task of parsing, typechecking, desugaring, and Core optimization remains with GHC, THC handles the compilation and execution of this Core via its own runtime on Truffle/GraalVM.
Notably, THC supports advanced language features like Template Haskell and Linear Haskell. Besides its JIT capabilities, THC offers AOT compilation using Native Image, generating standalone executables. The compiler adeptly handles packages through Cabal support, including those with multiple libraries and Backpack.
Foreign function interface (FFI) support allows THC to interact with other languages, integrating libraries and outputs seamlessly into the Haskell program. Conversion between Data.Text and Truffle strings via FFI is achieved through zero-copy for UTF-8-encoded strings.
Additionally, THC supports polyglot FFI to Python, Ruby, R, and JavaScript, enabling Haskell to tap into libraries from these languages and bring their functionalities into a JIT-compiled Haskell program. The implementation of quasi-quotation-based inline-language bindings is expected to be straightforward.
Finally, THC acknowledges the importance of performance, aiming for speed improvements ranging from 3× to 3× slower post-warmup, generally settling around 10–20% slower than GHC. However, recent benchmarking efforts have led to a 10× performance regression on certain easy benchmarks, which is currently being addressed. Further work is planned to ensure stack growth remains bounded relative to GHC's stack usage.
THC's source code is accessible at github.com/ekmett/thc, accompanied by comprehensive documentation on building, running, and utilizing THC. Development discussions take place on irc.libera.chat within the ##thc channel.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.