Haskell vs Purescript

I know this question has been answered to lot of places and I have read few of them. Recently I asked a question Is Haste compiler dead? - Links - Haskell Community, some people mention it better than Haskell. I want to know exactly how it is better. Because I came to know that GHCJs will get merge in the future. If it does then, how comparable will be with Purescript.

(I have asked this same question in both Haskell and Purescript discourse)

4 Likes

I guess I might have been one of the folks.

I did not want to say that PureScript overall is better than Haskell but records in PureScript are a lot “better” - meaning the record system is crafted into PureScript from the start, there are no issues with label-scoping, etc.

For me PureScript right now basically provides everything I usually work with in Haskell (type classes, fun-deps, …).
Yes GADTs and maybe type-families would be nice but to be honest for writing front-end it did not actually end up in a situation where this would really have improved my experience (IMHO this is different for library authors and probably for more complex domains)

As of how it’ll turn out if GHCJs will be merged in? I have no clue - for me this will very much depend on how the generated code will turn out.
Right now GHCJs is really impressive but the generated code is not (should say was not when I last checked - it was really big and I don’t really need or maybe don’t want laziness and async-execptions when working inside the browser).

Personally I think/hope I’ll stick with PureScript for a long time - it’s right in the golden middle between Haskell and Elm for me.

7 Likes

PureScript has @garyb which is a pretty big pro

11 Likes

PureScript certainly has plenty of differences from Haskell, but many of them are a matter of opinion and there isn’t a single “better” language. Any discussion of the differences should start with the docs on the matter, but I think there are some “philosophical” differences that aren’t mentioned there. I would say other differences include:

  1. Despite having as little as possible implemented in the core language and pushing everything else out to the library ecosystem, there seems to be just a single canonical way to do most fundamental things. There aren’t a bunch of different ways to raise/handle errors or deal with strings. (Though there are certainly many ways to do “higher-level” things, like there’s a lot of different UI frameworks.) There aren’t really any alternative preludes. Probably because
  2. PureScript tried to learn a lot from Haskell’s “mistakes” so the single standard prelude and common libraries look a lot more like what you’d see in one of the alternative preludes in Haskell. e.g., ideally, you will never run into a partial function in PureScript unless it’s represented with the Partial class.
  3. PureScript has a much smaller package library. You won’t get far without having to dip into the FFI (meanwhile npm/node.js has pretty much any package imaginable).
  4. It seems to me like you have to try a lot harder to shoot yourself in the foot in PureScript. The way I said it makes it sound like PureScript is objectively better, but sometimes doing something unsafe that you somehow know is just going to work takes a lot more effort in PureScript (Like writing an algorithm using arrays and indexing where you know that the indexes are all correct).
  5. PureScript isn’t as feature-rich, which is maybe just a restatement of PureScript doesn’t have language extensions.
8 Likes

I think there is a fundamental thing here that makes the answer to “Which is better?” actually something you can answer (for me): Language/runtime/ecosystem

The language of PureScript is, to me, plain better than Haskell. This is largely because of the benefit of hindsight and some key choices being made along the way that in aggregate have resulted in a nicer language to work with. I really do like Haskell and I’ve spent a ton of time writing about it, teaching it and generally arguing for it, but once I used PureScript it was clear to me that the language itself is just better put together.

The runtime(s): Node is a mess, in my opinion, and I hate using it. I hate designing things to run in it and I find it spectacularly ineffective for how popular it is. For a backend-focused project it’s unlikely that I’d choose PureScript with Node. Fortunately, PureScript is primarily a language, and it has support for multiple backends. With that taken into account my choice, if given carte blanche, is PureScript on the BEAM. The BEAM is a feature-rich, excellent runtime for robust, inherently concurrent applications. Designing systems in it is absolutely the best I’ve ever had. With purerl I can use what I think is the better language on a virtual machine that I’ve never experienced a real contender to in terms of system design.

Ecosystems: The PureScript side of PureScript-in-JS is mostly excellent but whenever I have to reach into npm land I feel like I’m running uphill. The amount of BS I’ve had to deal with when it comes to npm libraries makes me wonder how people actually get stuff done sometimes.

7 Likes