[HN Gopher] GHC now runs in the browser
___________________________________________________________________
GHC now runs in the browser
Author : kaycebasques
Score : 217 points
Date : 2025-11-01 16:29 UTC (6 hours ago)
(HTM) web link (discourse.haskell.org)
(TXT) w3m dump (discourse.haskell.org)
| buggery wrote:
| Interesting technical achievement but what would this be used for
| in practical terms?
| jes5199 wrote:
| yeah why would anyone want to run code on a website
| swannodette wrote:
| Loading 50mb of WASM is a big tradeoff just to run code on a
| website.
| tuveson wrote:
| 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 wrote:
| 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)
| bqmjjx0kac wrote:
| 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 wrote:
| 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 wrote:
| This is a show case of the wasm backend
| whateveracct wrote:
| GHC is built with GHC lol
| 0x264 wrote:
| Teaching
| fuzzy_biscuit wrote:
| I think the immediate and obvious case would be educational
| materials. Other than that, technical achievements need not
| always be practical to be cool :)
| linhns wrote:
| Agreed. Too many people said Haskell is only for academia,
| yet we're seeing more quality software being released in
| Haskell over the past few years.
| GiorgioG wrote:
| We are? Please share.
| Zambyte wrote:
| Pandoc is the first thing that comes to mind, but I also
| believe I have seen an uptick in software that I use
| being written in Haskell lately, though I can't remember
| what else off the top of my head.
| kreyenborgi wrote:
| I don't have the same impression, but
| https://github.com/PostgREST/postgrest and
| https://github.com/koalaman/shellcheck are some popular
| ones that may be useful to hn'ers.
|
| And https://github.com/mchav/dataframe?tab=readme-ov-
| file#datafr... is a library/framework that has had quite
| some velocity lately
| whateveracct wrote:
| https://mercury.com
| billti wrote:
| 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.
|
| https://quantum.microsoft.com/en-us/tools/quantum-coding
|
| https://quantum.microsoft.com/en-us/tools/quantum-katas
| anon291 wrote:
| 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
| IshKebab wrote:
| 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 wrote:
| 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?
| s-macke wrote:
| I will give a lecture about Haskell next week and might use
| this website for demonstration.
| pkage wrote:
| 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.
| kreyenborgi wrote:
| 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
| Johnny555 wrote:
| For those not well versed in Haskell, GHC is apparently this:
|
| https://www.haskell.org/ghc/
|
| What is GHC?
|
| GHC is a state-of-the-art, open source compiler and interactive
| environment for the functional language Haskell.
| mananaysiempre wrote:
| GHC (the Glasgow Haskell Compiler, after its original host
| university) is _the_ de facto 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 wrote:
| Does it use WasmGC, or bundle its own garbage collector?
| Tarean wrote:
| 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.
| zhangchi wrote:
| 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?
| umutisik wrote:
| 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.
| jiriro wrote:
| Cannot paste into the editor (safari on iphone).
| pjmlp wrote:
| Is it just me or is it actually impossible to type anything?
| mananaysiempre wrote:
| 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 wrote:
| Thanks, I have given up waiting it appears to take minutes on
| a phone.
| LelouBil wrote:
| I thought you were talking about typing in Haskell at first
| lol.
| edbaskerville wrote:
| They were! Typing...in Haskell...on a keyboard...on their
| screen...
| de6u99er wrote:
| Serious question. Is Haskell still a thing?
| teruakohatu wrote:
| Pandoc is an extremely popular Haskell tool.
| lrvick wrote:
| 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.
| nh2 wrote:
| Interesting logic:
|
| Declare something "dead" because it does not fulfill
| [extremely niche usecase that currently only few people care
| about] (boostrapped builds) and thus couldn't "even" be
| included in [project of the post author that takes a while to
| even find] (I eventually figured it must be referring to
| https://stagex.tools).
|
| There are probably 100x more people interested in Haskell
| than in build-bootstrapping (the Haskell reddit alone has 16k
| weekly users).
|
| What's next, calling JavaScript a dead language until it
| focuses on dependent typing?
|
| (I think bootstrappable builds are a good thing to strive
| for, but that should not be confused with language usage or
| what people really care about.)
| whateveracct wrote:
| https://mercury.com
| lrvick wrote:
| 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.
| rowanG077 wrote:
| 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.
| jdndndnns wrote:
| And where did you get the haskel compiler to do so?
|
| You seem to be missing the point of bootstrapping
| rowanG077 wrote:
| 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.
| lrvick wrote:
| 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 wrote:
| Ada can't bootstrap? Ironic...
| lrvick wrote:
| Yes, and that is a serious security problem because the
| only way to get trusted PCR values for TPM2 gated secure
| boot and full disk decryption applications, is with open
| source full source bootstrapped firmware.
|
| Coreboot is the only option, but it has a hard
| requirement on Ada because that is what they wrote their
| intel graphics stack in.
|
| It is a real mess.
| utopiah wrote:
| Interesting, any link I could read to understand a bit
| more the situation?
| leoh wrote:
| Sounds like an opportunity to rebuild an ADA interpreter
| rowanG077 wrote:
| I see, yes I most likely used a distro build ghc.
| gf000 wrote:
| Outside some fairly niche projects working on the problem,
| this is not a priority and most systems have straight
| binary dependencies.
| Ericson2314 wrote:
| https://discourse.haskell.org/t/what-s-needed-to-bootstrap-g...
| people have worked replaying the history to bootstrap.
| lrvick wrote:
| Looks like a work in progress still, but exciting someone at
| least put some time into this in the past year.
|
| Maybe some day I can have pandoc in security focused linux
| distributions...
| leoh wrote:
| This is wild. I didn't know this.
| yukinon wrote:
| For someone like me that is less versed in these things, could
| you explain why bootstrapping a language is a required check
| for taking a language seriously? My criteria is far less
| stringent (is it stable? is it popular enough? is the toolchain
| mature? etc..), so I wonder what I am missing here.
| Koffiepoeder wrote:
| I'm not the OP, but for me their comment sparked an
| association to the famous Ken Thompson lecture called
| 'Trusting Trust'. Could be a good starting point.
| whateveracct wrote:
| Between old Hugs and the new MicroHs, I think it's definitely
| doable with some elbow grease. I just don't know if anyone in
| the community cares that much about bootstrapping tho.
| zozbot234 wrote:
| AIUI, the underlying problem is that both Hugs and whatever
| toy Haskell implementations are available don't support the
| extensions current versions of GHC require. And no one has
| done the work to carve out a minimal stage0 compiler out of
| the GHC codebase that doesn't need those extensions to be
| built.
| 1vuio0pswjnm7 wrote:
| Actual title: "GHC now runs in your browser"
| utopiah wrote:
| Neat... but with QEMU-WASM I'm wondering what actually does _not_
| run in the browser (obviously that doesn 't required specific
| input).
|
| Not a criticism, love everything that can provide hassle-free
| onboarding to learn a new language, just curious.
| leoh wrote:
| My hypothesis -- worth testing -- is that this will be
| significantly faster
___________________________________________________________________
(page generated 2025-11-01 23:00 UTC)