GHC’s JavaScript Backend
summary
GHC now ships a technology‑preview JavaScript backend (based on GHCJS code) that generates Node/browser bundles, includes a JavaScript RTS with STG trampoline scheduler and reuses the JS GC instead of the C storage manager. It compiles Haskell primops to JS (Int64 as two-number emulation instead of BigInt), produces multi‑megabyte outputs today, lets you profile and monkey‑patch generated JS at runtime, and requires Emscripten+Hadrian to build; many libraries and optimizations remain to be ported or sped up.
AI-written summary · about
chapters (22)
- 0:00GHC’s JS backend intro
- 1:09Motivation for web backends
- 3:44JS backend specifics and RTS
- 8:09Managed platform challenges
- 12:10Code generation and toolchain
- 13:20Demo: Haskell to JS
- 21:01STG to JS compilation
- 28:38Comparison with GHCJS and its limitations
- 34:35Building the JS backend
- 40:33Implementation approach
- 43:32Roadmap and future
- 47:16Updating GHCJS libraries
- 51:07Demo: SVG in browser
- 1:04:47Execution model and heap
- 1:10:58Heap object construction
- 1:17:39Primitive type mapping
- 1:24:40Address and pointer handling
- 1:31:24Scheduler and tail calls
- 1:34:21Debugging JS modifications
- 1:38:17Template Haskell details
- 1:39:47JS backend components
- 1:40:09Contribution ideas
related talks
01h 22mCompiling Haskell to WebAssembly
30mThe future of Javascript
29mThe future of JS ans You
29mJavaScript in JavaScript: Inception
51mJavascript, the GNOME way
41mHaste: Full-Stack Haskell for Non-PhD Candidates
32mGPU.JS - GPU Accelerated JavaScript
27mJavaScript as a compilation target - Making it fast
