r/functionalprogramming • • Feb 07 '18

Question Purescript vs ReasonML/Bucklescript in 2018?

Which language would you pick for a new project in 2018, that has an imporant browser component?

Last year I looked into both, found the OCAML documentation and error messages extremly lacking, and enjoyed purescript much more.

However, it seems that purescript stagnated since and reasonml is building up steam.

What's your guys impression as of early 2018 regarding advantages, documentation, ecosystem (JS interop, well documented libraries) and future-proofedness (is this a word?) of these platforms and which one would you pick?


Edit one month later: Greetings to the visitors from the future! After playing around further, I gave up on Ocaml. For me

  • Error messages were completley useless. Everything would yield a "syntax error" with a seeming random line-number. In many cases the error message wasn't described, but encoured me to send pull requests with an updated message. These were obviously beginner mistakes, so nothing too fancy, and it forced me to scan every line manually to make sure all the ; and ) were in place.

  • I never got warm with the reason syntax. The javascripty look of reason made it more difficult to write than original ocaml/bucklescript, especially when to put ; {} () or not.

  • Tutorials/docs are rare and confusing. I never knew if I was learning Reason, Bucklescript or Ocaml

  • The toolchain only works if Reason, Bucklescript, Merlin and Ocaml are in very specific versions. Obviously the error messages you get are shit, so I spent far too much time on getting it running and I had to compile from source. Also, ReasonReact is it's own framework, so it's one more layer detached from react and data needs to be handed around between the components. All in all, updates are unpredictable and I don't trust the upgrade path.

  • Server side ecosystem is practically non-existent for modern use cases.

  • Apparently the majority of users are French students who learn Ocaml at university and there is very little adoption outside.

Final verdict for me personally: Unless there's a french guy in your team who already knows it, troubleshooting and boarding is hell and a time vapire. Also given the low maturity of the framework (error messages, old ocaml version, tutorials), I don't trust its upgrade path.

Maybe you get better results, but for me it's not worth it.


Purescript: Stagnated, but still nice. The React frameworks are terribly slow in benchmarks up to 8x slower than most of the field. For complex client side calculations and limited UI with a team that already knows haskell, I'd probably pick this.


Clojurescript: I stumbled upon it because its react frameworks perform amongst the fastest with less code, it's functional and immutable (with escape hatches). It's not typed, but it has Spec, which allows for quickcheck type autogenerated test cases, spec reuse for runtime validation and even regex and code-defined validation for what values are allowed into a type. The compiler is quick and clojure on the server integrated with the java ecosystem, it also has frameworks for react native.


All in all, this may sound blasphemous, but for me the most useful functional, typed frontend language is still Typescript with Ramda and Immutable.js. That gives me ADT, function composition, immutability, lenses, etc, with a rich ecosystem and easy boarding. Only thing I miss is type inference which makes me retype interfaces and types all over the place. For UI oriented applications Clojure(script) with Spec seems a nice fit. (I didn't check elm due to mounting negative feedback about breaking changes between versions). To use even more typed features purescript still the best, but be concious of the performance penalty.

26 Upvotes

22 comments sorted by

View all comments

1

u/yawaramin Mar 15 '18

Thanks for sharing your feedback. About Reason, I’d agree that compiler output syntax errors are not very helpful. But errors in VSCode with the ‘bsb’ diagnostic setting turned on is quite good. I’ll push for this to be one of the defaults going forward.

Docs could probably use some consolidation but I think it’s pretty simple to tell which you’re learning: if you’re on the Reason doc site, you’re learning Reason, and if you’re on the BuckleScript doc site, you’re learning BuckleScript, and in either case you’re learning OCaml 😉

About the toolchain, the working versions are all packaged in a single bundle: the reason-cli npm package. That, and the bs-platform package, should give you everything you need.

Server side is a work in progress, but there are several options on the OCaml side.

Adoption and French guys is a bit of a red herring 😉 if you’re interested, drop in to the Reason Discord and pick it up naturally like people all over the world are doing. It’s just a language like any other. Companies like Facebook, Jane Street, Docker, Citrix, Uber, Microsoft, are using OCaml. Check out the industrial users consortium.

2

u/user5543 Mar 15 '18

reason-cli

Didn't work for me on ubuntu. I don't remember the error, only that it took me forever to figure out. Finally, I ended up compiling from source.

I think it’s pretty simple to tell which you’re learning

From a newcomers perspective, it's not simple at all. For exampe: reason-cli doens't work and I get some unclear error message. Is this an ocaml problem? A bucklescript problem? A reason problem? I ended up solving it with the ocaml docs and a bucklescript walkthrough.

Same goes with learning other concepts. There are only sparse tutorials and examples online, so sometimes I end up with a blog post on bucklescript and sometimes on reasonml. For a lot of concepts, I find recommendations to read a chapter in Real World Ocaml or something similar.

The entire experience was just very bumpy and painfull, chasing unclear errors and wasting tons of time on things that are non-issues in other ecosystems. For me, it's definitley not worth the potential upsides.

It probably is different if you have a few experts on hand already, care about legal risks regarding license disputes with Microsoft and want to keep full control of your development tools.

And regarding the "French guys": I was surprised to see on google trends how concentrated the interest is in France (and the ex colony algiers). That led me to read up on the usage of Ocaml and I also found out that it came to Facebook with a French guy who learned it at university. Of course I wrote this with tounge in cheek, but it just reinforced my impression that none of these companies had to rely on easily available boarding as they had experts at hand to develop their inhouse programs.

1

u/yawaramin Mar 15 '18

Gotcha, and thanks again for such a detailed response. I believe the community and core team are all working quite hard on documentation and onboarding, so maybe in the near future it will make sense for you. I do think it’s still quite a good value proposition for anyone who has done or wants to do typesafe functional programming and deploy on JavaScript platforms. We’ve seen a good response from at least some portion of the JavaScript community, so I think we’re on the right track. But we do need to work on polish, onboarding, and documentation.

P.S. I honestly don’t know what you mean by licensing issues with Microsoft. There are no licensing issues. Reason and React are Facebook copyright and MIT licensed with no patent clause or anything like that, BuckleScript is copyright of Bloomberg and licensed under GPL (just like OCaml, obviously).

2

u/user5543 Mar 15 '18 edited Mar 15 '18

Yes, I think Ocaml/BS is a solid basis, and it's an interesting development, I'm sure I'll have another look in a year or two.

Regarding licensing: I just meant to say that giant companies like Facebook have strategic interests of not being too dependent on other players like Micrsoft or Google regarding their core development tools, be it potential legal disputes, roadmaps, etc. So they might have additional motivation not to rely on Typescript, but to develop Flow/Reason inhouse.

I didn't mean to imply that there are any licensing problems for users, sorry if I created that impression.