r/haskell • u/ForrestTrump • Oct 29 '17
Why is Elm more popular than PureScript?
I thought that PS offered most of the expressive power that Haskell has, without the language extensions.
Isn’t it a myth that PureScript is front end only? If your ultimate goal is to learn Haskell that you would use seriously, I suspect that preparing yourself with Elm first would be a waste of time. What do you guys think.
EDIT: Not that the purpose of Elm is to eventually move on to Haskell, but I can picture some people 'settling' for Elm if they think PureScript or HS are too hard to start with.
66
Upvotes
88
u/paf31 Oct 29 '17 edited Oct 29 '17
I think Elm focusses on learning and the ease of getting started. It's not to say PureScript doesn't focus on those things, but it's not our number one concern. We've been focusing on building the language instead. Our learning curve is much steeper for beginners because we assume familiarity (or willingness to learn) more concepts up front. If you're learning FP for the first time, I think it makes sense to start with Elm. Eventually, you might find you want more type system features, so you might move to PureScript - or maybe not, and that's fine too.
Also, we're not optimizing for adoption numbers. You might say we have a more of an "avoid (success at all costs)" mentality in that sense. I know that PureScript is never going to have a massive number of users. That's even a good thing in my opinion. It sits in a narrow niche, and you need to value a lot of the same things as the developers to start to see real value from it. But the users who do use it regularly tend to really like using it, and produce some amazing things with it.
48
u/tdammers Oct 29 '17
If your goal is to learn Haskell, then just learn Haskell.
If you want a practical language for client-side web programming (that is also a full-fledged backend language thanks to node.js), that is similar to Haskell, then PureScript
If you want a pure functional language for client-side web dev that is easy to learn, go with Elm.
33
u/edwardkmett Oct 29 '17 edited Oct 29 '17
Elm is easy to move into. It doesn't ask you to learn anything but syntax. You just don't realize that the abstraction ceiling is so low until a month later when you start hitting your head.
It also has the first-mover advantage. It was on the scene a long time before purescript got started.
Elm drags Javascript 20% of the way towards Haskell. Purescript drags Haskell 20% of the way towards Javascript.
There are a lot more Javascript developers than Haskell developers and each has been pushed pretty heavily at those target audiences respectively.
29
u/pr06lefs Oct 29 '17
I think a lot of devs aren't necessarily looking for expressive power in a language. They're looking for a way to stop making nightmare code bases. I think there's an impression that Elm has just enough complexity to get the job done on the front end, while still providing many of the benefits of strict typing, even if its not as elegant as its possible to be in a more full featured language.
Also, doesn't elm have better performance than purescript?
33
u/gelisam Oct 29 '17 edited Oct 29 '17
According to "Let's be mainstream! User focused design in Elm", Elm targets JavaScript programmers, optimizes its landing page's feature list to make its advantages clear to JavaScript programmers, and optimizes the wording of its documentation to eliminate scary words like "Monad". Simplicity and learnability are high-priority goals for Elm.
In my opinion, popularity is obtained by making the advantages as clear as possible and making the switching costs as low as possible. Elm is doing a great job on both, as outlined in the above video.
Haskell is doing a terrible job at both. Learning Haskell is much harder than learning yet another imperative language, and while I think that the clarity, correctness, and debugability which results is worthwhile, it's hard to succinctly explain how giving up on side effects magically leads to those benefits.
I am not super familiar with PureScript, but my impression is that it is trying to be a better Haskell than Haskell. It has an even more finely-detailed numeric hierarchy, for example, and its lenses are based on Profunctors instead of functions. Both of those sound like improvements to me, but to someone whose numeric hierarchy only has
float,intandBigInt, that's probably just going to be an even steeper learning curve.I don't think either Elm nor PureScript is designed to be a stepping stone towards Haskell, and I don't think most people who learn either language are using them as such. My impression is that most Elm learners come from JavaScript, while PureScript learners come from Haskell.
On the contrary, I do recommend learning Elm before Haskell. Like I said, Elm is designed to be easy to learn, so the learning curve will be a lot softer than Haskell's, and its teachings about purity, immutability and types carry over to Haskell. So even though Elm isn't designed to be a stepping stone towards Haskell, I think using it as such is a great idea.
13
u/jusrin Oct 29 '17
As a kind of typical case of JavaScript/Ruby/Java dev, I tried out Elm first because it was marketed quite loudly and it was the only option I knew of at the time (2015) other than F#, which I wasn't about to use for various reasons. I only found PureScript later when I was disappointed with Elm and I saw some stuff from Bodil on Twitter about PureScript.
That's about it. Nobody in my circles told me there was even an option.
Even today, if you talk to a JavaScript user who's "in the know" about things, they really only know about Elm and ReasonML thanks to the marketing efforts. PureScript, Fable, and GHCJS don't exist in their Twitter feeds.
9
u/brianmarick Oct 30 '17
I think that an ideal progression from Elm to Purescript would be:
At-- something I suspect people will want to use soon after being exposed to lenses -- you must first understandIndexand evenTraverse. I don't understand the appeal of such an approach.)7
u/1-800-BICYCLE Oct 30 '17
I’ve used both and had an easier time with Elm than with PureScript, although I don’t think I necessarily “enjoyed” either one more than I would have just enjoyed pure JavaScript.
For one, Elm has some really nice error messages. Second, there’s the whole “publish action -> update store -> notify subscribers” framework that tends to be a bit easier in terms of barriers to entry.
It also feels like PureScript is unmaintained. I tried PS out twice over a year or two and the docs were more or less the same (very sparse). The package manager as of like 6 months ago still used Bower, which has been phased out pretty much everywhere (even Bower devs say to stop using Bower).
A big issue for me, too, was that I felt like I was looking at Haskell docs to figure out how to do things more than I was using PS documentation. At that point, why not just use a Haskell compiler that targets JavaScript instead? And, if I end up using the FFI to include the majority of my JS code, can’t I just write functional JavaScript code in the first place and cut out the middle man? Even without the runtime requirement that Elm has, PureScript introduces a lot of framework and dependency cruft, which is in some ways worse (manually currying and wrapping functions to defer evaluation — the generated code is readable but uglier than, say, using Ramda).
6
u/absence3 Oct 29 '17
PureScript compiles to JavaScript, which is the "native" front-end platform. While it's possible to run PureScript generated JavaScript outside a web browser using Node, it probably makes sense from a performance perspective to limit the number of virtualisation layers. In that regard, PureScript is most useful on the front-end.
6
u/[deleted] Oct 30 '17
"Rigid/skolem type variable bound by x has escaped"
In all seriousness, I think it's because Elm has focused on bringing web devs to FP, not bringing FP devs to the web. Both have different niches and priorities. Elm puts a ton of effort into error messages and keeping the language minimal. As a result, it's not as generic and requires more boilerplate, but it's an easier sell to non experts.
17
u/mckeankylej Oct 29 '17
Elm is more popular than Purescript because of the go mentality. The idea that if a language is “simpler” and “slimmer” it’s better is an incredibly toxic idea IMO. Elm is truly a simple language. There are very few language features, and if you’re a JS dev coming from react there isn’t a huge jump in complexity. This simplicity on-boards new devs fast. The problem is you cannot express almost any typed functional abstractions in Elm. This cripples the language, and Purescript has all of Elms features and many more. I see absolutely no reason to use Elm, except to gain tech debt.
5
u/[deleted] Oct 30 '17 edited Oct 30 '17
One thing that stops me from learning PureScript is performance. Elm probably has the fastest virtual DOM implementation out there and I've seen some Halogen/Thermite benchmarks showing that the performance is much worse than even in JS frameworks. Not sure how accurate they are though.
8
u/vagif Oct 30 '17
Elm is not a scary functional language that takes years to master and requires reading bunch of PhD papers. It is a easy to learn web front-end development framework that can be picked up by any javascript junkie in a week.
4
u/[deleted] Oct 30 '17
Elm is --in most respects-- a DSL. PS is a much bigger language, and has good potential to be compiled to native (already an experimental compiler exists iirc).
If you want to create browser apps, and you have to teach the language+stack to some devs, then Elm is a very good choice. It's quite simple (PS has a lot more features/syntax to learn). It has batteries included (comes with a DOM lib; in PS you can pick your own from some options). It prescribes you the architecture (TEA which is a bit like React+Redux; in PS there are several frameworks/libs to choose from).
The go with PS. :)
3
u/[deleted] Oct 29 '17
It’s strict (which is big) and I don’t really think the language extensions are that big of a problem.
As I said, laziness is big enough that if your goal is to learn Haskell then I’d suspect you should start with Haskell.
Also Haskell is reasonably fast and PureScript is not as I understand it.
I think Elm was clever about the rhetoric they adopted, but I also don’t think it’s all true. Not that it hasn’t led to concrete differences in who makes up the community, though - watch some Elm talks and you’ll see differences.
2
u/TheZoq2 Oct 31 '17
Personally, I started with elm because I wanted to make something on the frontend, didn't want javascript and wanted a good type system.
I think that elm being simpler helped me get over the inital hurdle when learning my first functional language and the experience with elm is helping me learn haskell now, even though that wasn't my initial intention
1
u/nabokovian Nov 01 '17
Those compiler error messages!
1
u/throughnothing Nov 13 '17
I really think it boils down to a maniacal focus on user experience, even (and specifically) at the expense of language features.
Elm has awesome guides and tutorials for developers with no experience with "functional programming". Also, it's decision to avoid anything like typclasses has a cost of duplicated code, but with this lack of abstraction comes the ability to provide more helpful and clear compiler errors to new users. The same level of specificity of errors would be much harder, if not impossible, to achieve in Purescript given the higher level abstractions that are not only allowed, but commonplace amongst the standard libraries there.
I do also think Elm has put more time into better websites and marketing to some extend, though the Purescript community is doing great things there as well.
Succinctly, I think Purescript has historically "been ok with" targeting folks who already understand Haskell's concepts and functional programming in general, with a philosophy towards philosophical purity/rigor, and maximal code re-use + abstraction possibilities, while Elm is always willing to trade those things for (in their opinion) a better user (read: developer) experience.
Disclaimer: I'm much more a fan of Purescript personally, and have used Purescript much more than elm, so I'm biased towards Purescript.
1
u/victorhazbun87 Mar 24 '18
I'm a full stack developer tired of all the "new" freaking JS frameworks. Decided to go all-in with Elm since it can pretty much replace React, Vue, Angular or anything. The documentation is great, there are places to learn it and you get results without external libs, but not everything is cool... Elm is still a kid, I wish to see more open source projects but I understand that writting Elm could be difficult for most developers because it is a functional lang and we all know we love OOP. If you want to learn Elm, this is a great course https://pragmaticstudio.com/elm
1
u/sohang-3112 Jan 22 '22
One reason for Elm's popularity may be that it outputs everything - HTML, CSS and JavaScript, not just JavaScript. So you don't even need to deal with the HTML.
-1
u/kkweon Oct 29 '17
Elm is simpler and easier.
If one wants to build a todo application, One even without any functional programming language can create the app in an hour with elm.
With Purescript, well there is no way before knowing how to handle side effects.
It turns out people love simpler language especially coming from js background. As a haskeller, you will hate both or at least not like it as much as Haskell because after all it is not haskell.
Both languages make you feel like it is a web dev version of Haskell, but it is going to fail you at some point with some features missing.
0
u/[deleted] Oct 30 '17
I think elm is more popular than pursecript for two reasons.
First of all I think purescript and typescript were popular around the same time and I think that they were seen as competing. Most of the jobs have gone over to typescript and so that has lost purescript some users.
The second reason why elm might be winning out over purescript is that elm is a lisp and so it's easier to pick up if you already know another version of lisp.
0
u/[deleted] Oct 29 '17
[deleted] — view deleted comment