Statically typed functional language transpiliers (to Javascript)

PureScript is an entirely different language and the two cannot share code. Haste, Fay and GHCJS are actual Haskell subsets of varying completeness, where GHCJS compiles everything and Haste compiles anything that doesn’t use native C functions and Fay is much smaller.

As for the title question:

  • Haskell
  • Rust
  • OCaml
  • PureScript
  • Elm
  • Bucklescript

In terms of the last 3 on that list I’m continually researching which I would like to use. I’m most familiar with Elm and I think the very restricted scope of it allows to grasp it more easily, but I’m happier with the feature subset of PureScript (and even more so with GHCJS) and Bucklescript.

Rust is interesting because it seems like the only sane way to do lower level stuff without a GC nowadays and so I want to have it in the toolbox for completeness sake.

Haskell is the latest language I learned that I felt truly happy using; it’s simply a joy.

1 Like

Bucklescript is to OCaml as GHCJS is to Haskell, Bucklescript is just a backend for the OCaml compiler (a ppx plugin specifically), no new language (other than some useful annotations you can use, but you can use those in native compilation too, they are mostly useful for having things work everywhere, regardless of how it is compiled). :slight_smile:

Hence why its feature set is more complete and more satisfying than Elm, for example. The reason I like the ideas of GHCJS and Bucklescript is precisely how they don’t attempt to clone anything, but rather just serve a new platform.

What do you think about Reason, by the way?

Eh, a couple of the new syntax’s are nice, but most of it is very… verbose, javascripty… ReasonML is just a PPX on OCAML as well that gives it a new syntax, and that syntax was designed to ease Javascript programmers into OCaml, it does nothing for prior-existing OCaml users. It even has a React-bound JSX-like thing built-in as well, which just irks me for a couple of different reasons…

So now we have two MLs intended to get JS programmers into ML (Elm and Reason).

And PureScript…

I prefer OCaml straight. ^.^

On one hand I think people put way too much weight on syntax as being a factor in what they learn, but it’s impossible to deny that it matters to people. Certain languages pretty much only get turned down because of syntax. I wish people cared less about it, but all in all the people who care about it and end up being part of the ecosystem can end up being productive members of the community.

I asked about Reason because it seems to me it’s to OCaml what Elixir is to Erlang.

1 Like

Except Reason gains nothing over OCaml (heck even the JSX ppx they have works in OCaml). Elixir gains macro’s over erlang (which were hugely painful before, macro’s are the sole reason I use elixir over erlang, erlang is more consice and easy to read in my opinion ^.^).

I think macros pale in comparison to the fact that more and completely different people have entered the ecosystem as a consequence of it basically being a skin on top of Erlang. But yes, I like macros too. I wouldn’t dismiss the idea of Facebook putting a new skin on one of my favorite languages easily, because it’s sure to at least shine a spotlight on it.

I don’t think PS is trying to make it easy for the average JSer to use an ML language. PS, unlike Elm, doesn’t drop Haskell features just because they’re “hard”. For the most part it’s very similar. Still got typeclasses, monads, and the rest of the things that drive people away :smiley:

Yes, in that respect it’s more like a language that is aiming to get Haskellers to do JS than the other way around.

Lol, I could see that.

Cool, we got our own thread to rant about ML -> JS thingies :smiley:


Can you guys think of a better title? That’s just what I put in as I was splitting the posts :lol:

Lol. Hear hear! ^.^

Hmm, maybe Statically Typed Functional Language -> Javascript discussion? ^.^

1 Like

I believe I missed this topic the first time around.

If you are still looking for a way to comfortably use Haskell in the front-end, you might enjoy using miso, which is an elm-like Haskell(/GHCJS) library. The only thing it will not solve, is rather long compile times.

1 Like

For note, I’ve also found out that a subset of Racket (or languages built on it, like TypedRacket) can also be compiled to javascript. :slight_smile: