# JavaScript backend has landed in GHC

**URL:** <https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449>\
**Category:** Uncategorized\
**Created:** [December 14, 2022, 2:53pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449 "2022-12-14T14:53:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![doyougnu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/doyougnu/32/2248_2.png) [@doyougnu](https://discourse.haskell.org/u/doyougnu)\
**Post date:** [December 14, 2022, 2:53pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/1 "2022-12-14T14:53:08Z")

</div>

The GHCJS based JavaScript backend has landed in master: [JavaScript backend merged into GHC | IOG Engineering](https://engineering.iog.io/2022-12-13-ghc-js-backend-merged)

Aright now time to get back to make sure the CI actually runs the GHC testsuite on the JS backend 🙂

cc @hsyl20

---

<div class="post-metadata">

**Author:** ![Cmdv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cmdv/32/1167_2.png) [@Cmdv](https://discourse.haskell.org/u/Cmdv)\
**Post date:** [December 14, 2022, 6:48pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/2 "2022-12-14T18:48:50Z")

</div>

Nice 👌

Interested to know how the usability would compare with Purescript?

Just it’s fairly easy to port any JS library ie React via FFI in Purescript. Thus having most of the JS ecosystem at your feet (given one takes the time to FFI a library). Also last time I used PS it’s compilations was rather performant 🤔

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/nomeata/32/1188_2.png) [@nomeata](https://discourse.haskell.org/u/nomeata)\
**Post date:** [December 14, 2022, 8:55pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/3 "2022-12-14T20:55:54Z")

</div>

Exciting times!

Looking forward to update my few GHCJS using projects to just use GHC.

---

<div class="post-metadata">

**Author:** ![santiweight](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/santiweight/32/1187_2.png) [@santiweight](https://discourse.haskell.org/u/santiweight)\
**Post date:** [December 14, 2022, 11:38pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/4 "2022-12-14T23:38:51Z")

</div>

Congratulations! This is so exciting 🙂

I’m curious whether Miso/Reflex are thinking of updating to use this new port soon? What frontend tools does IOG use that pushed them to perform this upstreaming?

---

<div class="post-metadata">

**Author:** ![hasufell](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/hasufell/32/1250_2.png) [@hasufell](https://discourse.haskell.org/u/hasufell)\
**Post date:** [December 15, 2022, 2:25am UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/5 "2022-12-15T02:25:56Z")

</div>

> [@santiweight](#):
>
> I’m curious whether Miso/Reflex are thinking of updating to use this new port soon

@dmjio any updates on this?

---

<div class="post-metadata">

**Author:** ![atravers](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@atravers](https://discourse.haskell.org/u/atravers)\
**Post date:** [January 30, 2023, 8:13pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/6 "2023-01-30T20:13:51Z")

</div>

Considering the prevailing attitude towards JavaScript e.g:

> **[The less JavaScript, the better (Ep. 532)](https://stackoverflow.blog/2023/01/27/the-less-javascript-the-better-ep-532/)**
>
> Convert unused JavaScript into lightweight HTML...oh that feels so good.

…is building a back-section specifically for _that_ ol’ warhorse such a good long-term investment - would a better Internet-centric option be the new WebAssembly back-section:

> **[WebAssembly backend merged into GHC](https://www.tweag.io/blog/2022-11-22-wasm-backend-merged-in-ghc/)**
>
> Announcing the GHC WebAssembly backend – present and future

…which (presumably) could then be used to support or supersede JavaScript? Granted, WebAssembly isn’t perfect either e.g. [it’s data formats not being network endian](https://github.com/WebAssembly/design/issues/1212#issuecomment-394183533), but several other widely-used programming languages already or will have wasm support in the next few years…as opposed to supporting JavaScript.

If the old back-section for [C](https://techcrunch.com/2015/05/02/and-c-plus-plus-too/) was demoted from regular use in GHC, to then add a new back-section for JavaScript seems somewhat anachronistic…

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/nomeata/32/1188_2.png) [@nomeata](https://discourse.haskell.org/u/nomeata)\
**Post date:** [February 5, 2023, 5:23pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/7 "2023-02-05T17:23:48Z")

</div>

@doyougnu, is there a nix derivation and cache somewhere that I can use to play around with this, without building it myself?

---

<div class="post-metadata">

**Author:** ![TerrorJack](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/terrorjack/32/5155_2.png) [@TerrorJack](https://discourse.haskell.org/u/TerrorJack)\
**Post date:** [February 5, 2023, 5:42pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/8 "2023-02-05T17:42:16Z")

</div>

The JavaScript backend is already upstreamed in nixpkgs: [https://github.com/NixOS/nixpkgs/pull/208947](https://github.com/NixOS/nixpkgs/pull/208947)

---

<div class="post-metadata">

**Author:** ![doyougnu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/doyougnu/32/2248_2.png) [@doyougnu](https://discourse.haskell.org/u/doyougnu)\
**Post date:** [February 6, 2023, 1:52pm UTC](https://discourse.haskell.org/t/javascript-backend-has-landed-in-ghc/5449/9 "2023-02-06T13:52:57Z")

</div>

If you want to build from source (instead of pulling from nixpkgs) then you should use `ghc.nix` and follow the build instructions in the wiki: [javascript backend · Wiki · Glasgow Haskell Compiler / GHC · GitLab](https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend)

if you end up having issues with the llvm version then you’ll need to use my patched version of `ghc.nix` here: [GitHub - doyougnu/ghc.nix: Nix (shell) expression for working on GHC](https://github.com/doyougnu/ghc.nix) althoug it looks like nixpkgs have a better [solution](https://github.com/sternenseemann/nixpkgs/blob/6392c21c1fefd50d9dda8bec70bcbbf01622f769/pkgs/development/compilers/ghc/common-hadrian.nix#L338) so perhaps its time to update ghc.nix upstream!
