GHC now runs in the browser
47 comments
·November 1, 2025lrvick
Unfortunately there is still no way to actually bootstrap haskell (or anything based on it) which makes it impossible to put anything written in Haskell near any high trust linux distribution or environment.
I guess sandboxing the untrusted binary in a browser is -something- to let people play with haskell in a lower risk way for the moment at least but it is hard to take a language seriously or trust it with no way to bootstrap it from source.
Ericson2314
https://discourse.haskell.org/t/what-s-needed-to-bootstrap-g... people have worked replaying the history to bootstrap.
rowanG077
How is ghc compiled at all without bootstrapping? Or is there a magic binary in tree that is unreproducible? I have compiled ghc a few times and had no problems.
lrvick
Quite literally all distros today build it by downloading an existing magic binary to compile the latest sources. Even if they claim the package is reproducible, all bets are off on trust if it downloads a prebuilt binary in the build process. It is a prime Trusting Trust attack target.
The only other somewhat widely used language I am aware of in this bad of a position is Ada. Every other language I am aware of has a clear bootstrap path.
icrbow
Ada can't bootstrap? Ironic...
rowanG077
I see, yes I most likely used a distro build ghc.
jdndndnns
And where did you get the haskel compiler to do so?
You seem to be missing the point of bootstrapping
rowanG077
Maybe that is literally why I asked the question, clearly I don't know as I have not spend the time investigating this problem that the commenter has. Asking some kind of gotcha question is not helpful.
umutisik
This is very impressive. I once built an educational Haskell programming + math. + art web site (mathvas.com). Something like this would have simplified that a lot.
zhangchi
Can someone please help me understand the difference between features like this and the technologies like Blazor Wasm which actually let you write frontend in non js for websites?
Johnny555
For those not well versed in Haskell, GHC is apparently this:
What is GHC?
GHC is a state-of-the-art, open source compiler and interactive environment for the functional language Haskell.
mananaysiempre
GHC (the Glasgow Haskell Compiler, after its original host university) is de facto the Haskell compiler and simultaneously the main research vehicle for the language and the neighbouring design space in general.
And frankly, while the compiler is awesome and so is the research, the constant churn and seeming inability to settle on what the good programming style and set of features actually is is what eventually turned me away from the language and to the more stable (if near-abandoned) pastures of Standard ML. (That was during the type families upheaval, so, about ten years ago? Don’t know how well it reflects the current state of the project.)
frou_dh
Does it use WasmGC, or bundle its own garbage collector?
Tarean
I think WasmGC is very hard to make work with laziness. A lazy value is always a closure on the heap.
If an expression might be unused, throw a closure which computes it on the heap
If the value is actually needed, invoke the closure. Optionally replace the closure with a black hole. A black hole is just a closure which pauses any thread which calls it, to be resumed once the first thread finishes with the expression
Once finished, replace with a closure which immediately returns the computation result. (Or often save the indirection because most concrete values also act as closures which immediately returns themselves using info table pointers trickery)
Anyway, iirc WasmGC wants very rigid types without dynamic type changes. Extra indirections could fix that, Oor maybe defunctionalizing thunks into a tagged union, but both sound expensive. Especially without being able to hook into the tracing step for indirection removal.
Also, Haskell supports finalizers so WasmGC would need that as well.
singpolyma3
[flagged]
pjmlp
Is it just me or is it actually impossible to type anything?
mananaysiempre
Just you. Once the editor actually loads (turning the “Haskell source” pane on the left from the page background’s deep violet into a dark gray and displaying a “hello world” program), I can type perfectly fine. And I’m using a browser based on WebKitGTK, which is not exactly known for its stellar compatibility.
pjmlp
Thanks, I have given up waiting it appears to take minutes on a phone.
LelouBil
I thought you were talking about typing in Haskell at first lol.
buggery
Interesting technical achievement but what would this be used for in practical terms?
s-macke
I will give a lecture about Haskell next week and might use this website for demonstration.
kreyenborgi
For one, it demonstrates how far the ghc wasm backend has come, in that such a large system as ghc itself can now run in wasm
jes5199
yeah why would anyone want to run code on a website
bqmjjx0kac
It would be more plausibly practical if GHC could now target wasm, but this announcement is actually about being able to run the compiler itself in the browser.
tempay
It can target wasm, the point of the post is that it’s now mature enough to be able to build itself for wasm and run in a browser.
Jaxan
This is a show case of the wasm backend
swannodette
Loading 50mb of WASM is a big tradeoff just to run code on a website.
tuveson
Loading time is pretty rough, but it seems responsive enough after the initial load. Probably as fast or faster than downloading and installing GHC locally.
wslh
I would assume that in the near future one can preload, cache, update selected WASM packages. I also imagine that sooner than that we can preload open models in the browser to run the natively instead of only invoking third parties (e.g. window.ai in the DOM)
pkage
In addition to the other responses, it's also worth noting that wasm itself is useful outside of the web itself; e.g. in containerized applications.
fuzzy_biscuit
I think the immediate and obvious case would be educational materials. Other than that, technical achievements need not always be practical to be cool :)
billti
That’s one of the primary reasons we built the tooling for Q# to run in the browser (by writing in Rust and compiling to wasm). The “try with copilot” experience [1] and the “katas” for learning [2] all have a full language service and runtime in the browser.
IshKebab
Have you ever used Godbolt? The Rust playground? The Typescript's playground? The Go playground?
It lets you have that without the pain of hosting compilers server side.
westurner
From "WebR – R in the Browser" (2025 https://news.ycombinator.com/item?id=44999706 :
> jupyterlite-xeus builds jupyterlite, Jupyter xeus kernels, and the specified dependencies to WASM with packages from conda-forge or emscripten-forge.
jupyterlite/xeus https://github.com/jupyterlite/xeus
There may be an easy way to wrap GHC with jupyterlite/xeus, with Haskell's lazy evaluation; xeus-haskell or xeus-ghc?
null
anon291
Compilers are complicated. WASM has been a priority for the Haskell community for a while. Demonstrating GHC's ability to compile itself to WASM is thus a show that it is robust enough to compile a very complicated program into this backen.d
de6u99er
Serious question. Is Haskell still a thing?
teruakohatu
Pandoc is an extremely popular Haskell tool.
lrvick
We cannot even include it in stagex because there is still literally no way to compile it from source and thus no way to do a real reproducible build, and there is no one left that cares about the language enough to do this.
Honestly it has to be regarded as a dead language until this is resolved.
amelius
Very nice, but since WebAssembly was announced some time ago I'm kind of expecting anything to run in the browser by now.
Actual title: "GHC now runs in your browser"