6 ms·
GHC now runs in the browser
- buggery 1y agoInteresting technical achievement but what would this be used for in practical terms?
- jes5199 1y agoyeah why would anyone want to run code on a website
- swannodette 1y agoLoading 50mb of WASM is a big tradeoff just to run code on a website.
- tuveson 1y agoLoading 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 1y agoI 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)
- extraduder_ire 1y agoFor comparison: the homepage of cnn.com right now is 33.37MB on my machine. 16.82MB of which is JavaScript.
- bqmjjx0kac 1y agoIt 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 1y agoIt 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 1y agoThis is a show case of the wasm backend
- whateveracct 1y agoGHC is built with GHC lol
- 0x264 1y agoTeaching
- fuzzy_biscuit 1y agoI think the immediate and obvious case would be educational materials. Other than that, technical achievements need not always be practical to be cool :)
- linhns 1y agoAgreed. 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 1y agoWe are? Please share.
- Zambyte 1y agoPandoc 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 1y agoI don't have the same impression, but https://github.com/PostgREST/postgrest https://github.com/PostgREST/postgrest and https://github.com/koalaman/shellcheck 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#dataframe https://github.com/mchav/dataframe?tab=readme-ov-file#datafr... is a library/framework that has had quite some velocity lately
- whateveracct 1y agohttps://mercury.com https://mercury.com
- simonmic 1y agohttps://joyful.com/Haskell#What+are+some+Haskell+apps https://joyful.com/Haskell#What+are+some+Haskell+apps
- deleted 1y ago[deleted]
- anon291 1y agoCompilers 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 1y agoHave 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 1y agoFrom "WebR – R in the Browser" (2025 https://news.ycombinator.com/item?id=44999706 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 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 1y agoI will give a lecture about Haskell next week and might use this website for demonstration.
- pkage 1y agoIn 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 1y agoFor 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 1y agoFor those not well versed in Haskell, GHC is apparently this: https://www.haskell.org/ghc/ 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 1y agoGHC (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.)
- themk 1y agoHaskell now has "editions" which are essentially an agreed upon stable set of useful extensions. https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/control.html https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/cont... This makes the language feel a lot less experimental, as you don't generally have to enable 10s of extensions to get things working.
- bigstrat2003 1y agoYou know... all these years, I thought GHC stood for GNU Haskell Compiler. Interesting to learn the actual name.
- retrac 1y ago> more stable (if near-abandoned) pastures of Standard ML There's dozens of us! Hundreds maybe! It's not abandoned. It's more like with Lisp where the language is complete. Almost perfect as-is. Nothing left to take away and nothing left to add. Except Unicode and record update syntax. The deciding factor for my personal projects was that SML is the exact same language it was 30 years ago. And it will be in 30 years. Though if you stick to Haskell 98/2010 it is similarly stable. Speaking of SML and functional languages in the browser, MLton has a WASM target now: http://mlton.org/RunningOnWASI http://mlton.org/RunningOnWASI
- frou_dh 1y agoDoes it use WasmGC, or bundle its own garbage collector?
- Tarean 1y agoI 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.
- zozbot234 1y ago> Anyway, iirc WasmGC wants very rigid types without dynamic type changes. You can have dynamic type changes in the current WasmGC MVP, but they are modeled as explicit downcasts from a supertype of some sort. There's not even any express support for tagged unions, structs and downcasting is all you get at the moment.
- singpolyma3 1y ago[flagged]
- pjmlp 1y agoWasmGC is still a 1.0, there are many kind of GC semantics that it cannot handle, for example it still doesn't cover all use cases needed for languages like C# and Go, e.g. interior pointers.
- zhangchi 1y agoCan 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 1y agoThis 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 1y agoCannot paste into the editor (safari on iphone).
- pjmlp 1y agoIs it just me or is it actually impossible to type anything?
- mananaysiempre 1y agoJust 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 1y agoThanks, I have given up waiting it appears to take minutes on a phone.
- LelouBil 1y agoI thought you were talking about typing in Haskell at first lol.
- edbaskerville 1y agoThey were! Typing...in Haskell...on a keyboard...on their screen...
- internet_points 1y agoHm, works fine here (Firefox on Ubuntu). But getLine doesn't seem to be implemented, so there is output but not yet input :)
- deleted 1y ago[deleted]
- de6u99er 1y agoSerious question. Is Haskell still a thing?
- teruakohatu 1y agoPandoc is an extremely popular Haskell tool.
- lrvick 1y agoWe 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 1y agoInteresting 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 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.)
- lrvick 1y agoI said it has to be treated as a dead language. I did not say it actually is one. Being able to compile a compiler without binary blobs is a hard prerequisite to using that language for any application where security matters. A language can have an active community and still be unsuitable for any real world use cases. Fortran is bootstrappable so I consider it more viable than haskell for real world use, even though it has far fewer fans (understandably). Maybe it is more fair to call haskell an academic language or hobby language since it prioritized language design over basic supply chain security thus far. If it becomes bootstrappable, then of course all the above critique is immediately retracted.
- lrvick 1y agoUnfortunately 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 1y agoHow 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 1y agoAnd where did you get the haskel compiler to do so? You seem to be missing the point of bootstrapping
- rowanG077 1y agoMaybe 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 1y agoQuite 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 1y agoAda can't bootstrap? Ironic...
- 1vuio0pswjnm7 1y agoActual title: "GHC now runs in your browser"
- utopiah 1y agoNeat... 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 1y agoMy hypothesis — worth testing — is that this will be significantly faster
- syahlanah 1y ago[flagged]
- kaoD 1y agoCan anyone point to a "practical Haskell" tutorial/book/whatever for people that already know functional programming? I'm in this sour spot where most tutorials are boring to me so I just can't follow through. I know what a monad is. What a typeclass is. Even what HKTs are. I can make sense of "a monad is just a monoid in the category of endofunctors" if I give it a few minutes to unravel the ball of twine... But I wouldn't be able to code a "ToDo list" in Haskell if my life depended on it. Pls help.
- thethimble 1y agoYou might be better served talking to ChatGPT/Claude so it can tailor explanations based on your level of understanding. I've found that being super clear about concepts you understand well vs concepts you're unclear about makes for really effective explanations.
- joelwilliamson 1y agoHave you tried Real World Haskell?
- cosmic_quanta 1y agoThat is a really tough spot to be in. I don't know of any content that's aimed at someone like you. You might be interested in reading the Monday Morning Haskell blog[0] series, which presents examples of how to do certain tasks in Haskell. See [1] for an example. [0]: https://mmhaskell.com/blog https://mmhaskell.com/blog [1]: https://mmhaskell.com/blog/2025/5/19/comparing-code-leetcode-problems-in-rust-vs-haskell https://mmhaskell.com/blog/2025/5/19/comparing-code-leetcode...
- irusensei 1y agoCan the Haskell people help me refresh my memory? I remember running a Haskell interpreter on an HP Jornada running Jlime Linux. It was a long time ago in high school and I felt it was great because I thought it was a convenient way to do math classes since I could input some math formulas directly into the interpreter pretty much as they were. Definitely better than the Cassio scientific calculator my math teacher had us use. It ran from a CF card so there was no chance it was as big as GHC. I can't seem to find the name of the interpreter.
- AntiRush 1y agoI'm guessing it was Hugs: https://www.haskell.org/hugs/ https://www.haskell.org/hugs/
- irusensei 1y agoYes! Thank you. > Hugs is no longer in development The last release was in 2006 it seems. No wonder it was hard to google it. Its also interesting knowing someone compiled and published this interpreter for the Jornada Super-H CPU.
- dmjio 1y agoYes we do. https://github.com/haskell-miso https://github.com/haskell-miso