DEV Community

Giancarlos Isasi
Giancarlos Isasi

Posted on • Updated on

Should I learn ReasonML or Elm?

Folks! I want to learn other languages/technologies to build client-side feature. What should I choose? ReasonML or Elm?

Latest comments (5)

Collapse
 
antonrich profile image
Anton

You will probably learn both to some extent. Try them both for a week and decide. Or make your time table (it could be a month, or less or more).
I guess trying them both would be the most viable option. Because you will gain your own experience and perspective.

Collapse
 
antonrich profile image
Anton

For comparison check out the "Space Invaders" game in both:
Elm -> github.com/gege251/space_invaders
ReasonML => github.com/js-republic/reason-ml-w...

Collapse
 
nestedsoftware profile image
Nested Software • Edited

If you're new to functional programming, I think Elm may be a bit easier to get started with, since it is both a language and a front-end framework. The framework part is similar to React with Redux (Redux used Elm as inspiration).

I think ReasonML just lets you compile to javascript out of the box, so (if I am not mistaken) to get a front-end framework, you'd need to add an additional library, like Bucklescript-TEA or ReasonReact

Elm is also a pure functional language. If you haven't programmed in a pure functional language before, learning Elm first may be a good idea. That way you get to appreciate both the pros and cons that are involved.

I think ReasonML is more flexible - you can choose to make functions impure if you wish. This makes it easier to get some things working, but it also places more of a burden on you to exercise your own self-discipline. Maybe you can make more of an informed decision about relaxing those constraints once you've got some experience under your belt in a language where you don't get to make that choice - kind of like learning to ride a bike with training wheels first.

I'm not saying you should stick with Elm in the long run - ReasonML seems to have a lot more industry support - just that of the two, Elm may be simpler and quicker to pick up first.

Collapse
 
yawaramin profile image
Yawar Amin

Basically, you are right. I would just add that ReasonML's JavaScript compiler, BuckleScript, comes with a scaffolding system so it's pretty easy to get started with a ReasonReact project:



# Make sure you have write access to /usr/local/.../node_modules
$ npm install --global bs-platform
$ bsb -init my-reasonreact-project -theme react
$ cd my-reasonreact-project
$ npm install
$ bsb -make-world # compile all dependencies
$ bsb -w # watch mode
# Start hacking...
Collapse
 
yawaramin profile image
Yawar Amin

I'm biased, but I recommend ReasonML. The ReasonReact binding ( reasonml.github.io/reason-react/ ) is very high-quality, and there is also an Elm clone: github.com/OvermindDL1/bucklescrip...

There's very polished support for GraphQL, with code generation from queries: dev.to/iwilsonq/reasonml-with-grap...

There is also a high-quality React Native binding: github.com/reasonml-community/bs-r...

And these are just things that compile to JavaScript. There are more options out there if you want to build clients compiled to native binaries.

Interestingly, if you do decide to go with Elm, there's also an exit strategy to convert to Reason: github.com/darklang/philip2