Someone will have to explain why I might pick ReasonML over Elm for front-end development. Elm's community seems very focused on making front-end development as intuitive and hassle-free as possible. ReasonML seems like Facebook just wanted to leverage a pre-existing community but couldn't bring themselves to adopt the syntax so rewrote it in-house.
> Someone will have to explain why I might pick ReasonML over Elm
* bigger team (Elm the lang itself is almost a one man show)
* openly developed (Elm's dev't is in private, for now at least)
* interop with JS is easier
* great interop with React
* has a company behind it (FB), who uses it in production (messenger.com)
* already works on the server (with Node and with experimental native compilation (bsb-native))
* server-side native compilation is within the vision the core team (not so much with Elm)
* a lib exists for The Elm Architecture (TEA), see the bucklescript-tea package
* JS'ish (C'ish) syntax (Elm has an ML like syntax) -- this may or may not be your thing, I think it makes FP more accessible
* not pure functional (like Elm), thus allows mutation and side effects -- this may or may not be your thing, it makes interop with JS easier but comes with less strong safety guarantees
> Elm's community seems very focused on making front-end development as intuitive and hassle-free as possible.
Elm's community is great, but probably smaller than ReasonML's community in the long run, as I expect FB to use it a lot internally and thus has a great patron. Also, most big tech has their own language: Apple/Swift(ObjC), Google/Go(Dart), Mozilla/Rust, FB/Reason. I think it is the only language that potentially facilitate both FE, mobile and server-side dev't. It's a very interesting pick at this point.
> ReasonML seems like Facebook just wanted to leverage a pre-existing community but couldn't bring themselves to adopt the syntax so rewrote it in-house.
Yes. And to me this does not sound bad. They took OCaml, and BuckleScript, then added a new syntax, some tooling and libraries. They positioned a language that ticks a lot of boxes in a very short time, and since it has free interop with OCaml it comes with quite a strong lib ecosys for native (server-side) dev't.
Elm is cool, the BDFL seems like a great guy, but he's a bottleneck and the community is too small. I developed our internal Dashboard using Elm and we have already end-of-lifed it primarily for this reason. I think it's always going to be a niche product and I can't justify betting my business on that. Other larger communities are going to take these ideas and execute on them better.
The only way I see this changing is if Evan massively delegates responsibility, and I just don't see that happening. Elm is cool because it's small and tightly controlled, but that also limits its viability and growth potential.
ReasonML has a much more advanced module system via Functors. As far as I know Elm has nothing like this. Despite a fair few arguments over incorporating type classes into Elm, the creator is pretty dead set against the idea.
This does make Elm a lot more approachable, but after a while can feel quite restrictive.
There is bucklescript-tea, which is the Elm architecture in for Bucklescript (and thus also Reason). It is pretty much an exact match, so technically there isn't really anything you are missing out on by going with Reason. In reality the Elm community is more mature which means there is more documentation and libraries available. However bucklescript does interface to javascript a LOT easier - which does open up a much wider ecosystem of javascript libraries.
Agreed, I love Elm but the lack of documentation was a pretty big hurdle for me. Especially because I came from using elixir/phoenix on the backend which I found had excellent guides and docs (for language, framework and most packages).
No runtime. ReasonML is a language that has decent interop capabilities with javascript through the bucklescript compiler. You can use it to write drop in ready code segments into an existing codebase.
Hello world in ReasonML will get you a single line javascript output. Last I looked, the Elm bundle is in the 10s of kbs for something like that because you get the whole architecture.
Add is ReasonReact and it's a little more comparable obviously.
I ran into this question a lot when speaking about ReasonML, and am quite a fan of Elm as well. I wanted to address it holistically, so (if you'll forgive the shameless plug), I did a talk on some of the motivations of ReasonML (as I see them) and a high-level comparison to Elm here https://vimeo.com/242081961
Having recently started learning Elm, I am considering switching over to ReasonML. Elm's architecture is really great for front end development and the error messages are awesome, but the ecosystem is in its infancy, and development is driven by just one guy. I've seen a lot of open PRs and issues on Github with genuinely great features, but haven't been merged in yet.
ReasonML's documentation also seems better (especially for a functional programming newbie)
I am not advocating anything in particular as I am in the process of choosing the next language to learn. That said, I have watched some talks by Cheng Lou and some others about ReasonML.
Elm is just "Elm"... that isn't a bad thing and it seems like it is more mature at the moment.
ReasonML is Ocaml that plays nice on any screen anywhere thanks to Bucklescript. It also plays nice as a systems language. That is, unikernels... I am not even sure what they are, but they sound awesome and I want that.
> why I might pick ReasonML over Elm for front-end development?
I think ReasonML is better compared to TypeScript and Flow, rather than Elm.
Elm is pure, but I would still want to write my JS ports in a statically typed language. I would use TypeScript, but here is the project that let you use ReasonML[1]
I would also like to know if ReasonML makes some "guarantees" of zero runtime errors like Elm does. That's one reason what makes Elm attractive to me, though I haven't programmed much in it.
It does not. sgrove posted this above https://vimeo.com/242081961 which is a talk he gave. Ended up watching it all the way through and came away being happier with ReasonML than I was before (eh, preconceptions because Facebook). It is a good talk, but please ignore the graphs because they aren't scientific in any sense of the word - more emotional appeal statements.
Actually, the Reason team is basically made up of experienced OCamlers who wanted to attract the JavaScript community and figured that a familiar syntax would help a lot (I think they were right). See https://reasonml.github.io/docs/en/what-and-why.html#why-rea... for more details.
Maybe not the right place to ask, but "Better standard library" appears in the section detailing future improvements that ReasonML might bring to the OCaml ecosystem. How do they plan on doing this, given that the major standard library camps seem relatively entrenched in OCaml today? Which one does the ReasonML community favor/intend to contribute to?
Base[1] is a good candidate for an OCaml standard library. It's got tons of functionality, results in binaries with small footprints, is cross-platform, and has a fairly stable API. It's also code that has been and continues to be battle tested every day in production systems at Jane Street. I'm biased, as I'm one of the maintainers, but trust me it's good, it's good.
I'm not convinced that Base will solve our problems.
It's not, afaik, more portable, more lightweight, more performant, or more feature-full than [containers](https://github.com/c-cube/ocaml-containers) (which has reached 1.0 and also does a bit of IO and Unix, as a stdlib extension). In addition to that it's not compatible with programs that use the stdlib right now, so the fragmentation will stay for a long time (unlike for build systems where you "only" have to change the build scripts, not the code itself).
Core depends on Base. The parts where they differ include: more data structure, and bindings for system calls and other functionality available from libc.
There's also core_kernel, which is core but without the libc support.
(As of 12/2017, relicensed to straight MIT from BSD+patent.)
Rauschmayer's work here makes me interested in the language and motivated to learn it. After reading more, only wish I'd explored for a recent project where I was working to implement a lot of functional patterns in native JS.
Any thoughts about ReasonML vs "straight" OCaml? (Or does that question even make sense?)
Someone can correct me, but Reason is just a syntax on top of Ocaml's compiler. Bucklescript and Reason even share the same site design. there's not much of a choice beyond what you like more, as they use the same libraries, tools, etc.
Does anyone know where this new wave of interest came from?
Community. The Reason team focused on building it, and neatly embraced and nurtured BuckleScript in the process. It's a symbiotic relationship and the community has a reputation for being very newbie-friendly to boot.
> Any thoughts about ReasonML vs "straight" OCaml?
I've heard of (and from) web developers who say that they find OCaml impossible to read, but that ReasonML is easy and pleasant for them. So part of this is what you are used to, and another is subjective preference.
As someone that got introduced to ML via Caml Light, I really don't have any issue with OCaml's syntax, which seems to be the only reason (no pun intended) for ReasonML's existence.
It's a good question. Reason includes some major syntactic conveniences that make the JavaScript interop more pleasant to work with. One of the biggest ones is that it introduces a first-class syntactic JavaScript object literal (i.e. a Reason/BuckleScript value which will compile down to a JavaScript literal) and which makes writing JS objects much more pleasant.
There are other conveniences as well, including the fact that Reason comes with a tool (refmt) that can autoformat your code to a standard style, wiping out style guide arguments etc.
How would you compare ReasonML with ClojureScript, why or when should one be used over the other, what are the strengths and weaknesses of each in areas like JS interop, productivity, maintainability, creative prototyping and exploring, and so on?
Why should someone unfamiliar with functional style programming be learning ReasonML rather than say, something like, haskell? Looking for concrete, technical answers.
I view this as more of a general, why should somebody learn Ocaml instead of Haskell?
There's a couple of reasons.
#1. Ocaml's type system is nearly as expressive as Haskell's and includes several features that Haskell's does not. Polymorphic variants and functors being notable ones.
#2. Laziness is very hard to get right in practice. I'm sure Haskell enthusiasts will not be very happy with that statement, but I think it's true. It's the reason why one of the biggest users of Haskell (and the most notable example of Haskell in industry), Standard Chartered, uses their own Haskell compiler that's strict by default.
for comments from the Haskell community, including GHC maintainers.
Really though, I don't think you can really go that wrong with either. Transferring from each language to the other one isn't very difficult, and they're both excellent languages.
For those who don't already know an ML, just saying "functor" isn't helpful (the term is too overloaded). "Parameterized modules" might be a better term for that context.
For those who don't know, ML-style modules are significantly more interesting than most module systems, and let you pass modules as arguments to modules at import.
I wrote this on my phone a couple hours ago, and I wanted to add a couple qualifiers that might be misleading to people.
Laziness being hard to deal with isn't the only reason Standard Chartered uses their own compiler that's strict by default. However, they have noted that they do think strict haskell is a lot easier to deal with.
> they have noted that they do think strict haskell is a lot easier to deal with
That's news to me. Where did they note that? Lennart Augustsson explicitly says "I don't think strict or lazy matters that much in practice; they both work fine".
> Their experience with strict semantics has been positive. Particularly useful is the ease
of obtaining meaningful stack traces, tracking resource usage, debugging and exception
propagation. The chief downside of strict semantics, in their experience, is the increased
difficulty of modular composition
FWIW, I am a bit jealous of how laziness makes it easier to achieve function composition, and that was something that I wish was easier in strict semantics.
The quoted passage can be interpreted as one - presumably the implication is that it had those attributes relative to alternative semantics (and might have been expected to do so).
It's unfortunate that a short passage from an article not even written by either of the authors of Mu would be taken as evidence that SCB thought that strictness was better than laziness.
> So strictness is really fantastic, I must say. Stack traces work. When something goes wrong, you can say "so you call things from there to there to there". It's the single most time saving thing from Mu compared to Haskell, because things do go wrong from now and then, and it's so great to know exactly what went wrong... And strict languages have what I call resource composition. So if you understand the complexity of 2 parts you can stick them together and nothing weird happens. They add up. That's not true in lazy languages. And debugging, it's sensible in strict languages. And exceptions, they actually work! Strictness is great. It's terrible, also. So it has nice resource composition but it doesn't compose nicely semantically. So laziness has some good things as well. I think laziness is a much nicer way of programming except for these pesky resources. You definitely need some lazy functions, even C has lazy functions.
And then he goes on to talk about the ways that they allow laziness in a strict language, and when they need laziness.
Screenshots of relevant slides. Considering that the report was pretty much a summary of the talks given at CUFP, I don't know why you would cast doubt on its legitimacy.
It seems we have have got a bit off track and my quite precise claims have got lost. My claims are that
1. It is incorrect to claim that "Laziness is very hard to get right in practice. ... It's the reason why ... Standard Chartered, uses their own Haskell compiler that's strict by default."
2. Rather, the reason Mu is strict is that it was designed to target an existing strict runtime (I offer this claim without proof but I was told this directly by one of the authors of Mu).
3. It is incorrect to claim that Standard Chartered "think strict haskell is a lot easier to deal with"
4. Rather, Lennart Augustsson holds that each has their upsides and downsides. He says "I don't think strict or lazy matters that much in practice; they both work fine" and "I think laziness is a much nicer way of programming except for these pesky resources."
My claim that Standard Chartered thinks "strict haskell is a lot easier to deal with" comes from this comment from Lennart.
> If my only concern was semantics (i.e., input-output behavior) then I'd prefer call-by-name semantics, because I think it behaves more compositionally. But for practical concerns like resource consumption, debugging, stack trace, etc then strict evaluation is better.
Overall though, you're right that my initial claims against strictness may have been a bit too harsh. If I could edit my initial comment, I would write something more like
> 2. Laziness is often hard to use in practice. As Standard Chartered, a company that uses a strict variant of Haskell, notes: space leaks, difficulty of debugging, and hard to decipher stack traces are downsides to laziness.
In my opinion, laziness definitely does have nicer semantics than strictness. It's more expressive and easier to compose. In practice though, I prefer strict languages mostly for the reasons Standard Chartered mentions.
> It's the reason why one of the biggest users of Haskell (and the most notable example of Haskell in industry), Standard Chartered, uses their own Haskell compiler that's strict by default.
No it's not. The reason Mu is strict is that it was designed to target an existing strict runtime.
Haskell will take months of brain twisting before you really understand what is going on and can do anything productive. ReasonML, you could be up and running within a week. (Timescales are just a random guess, but you get the idea..)
Plus ReasonML isn't strictly functional. You can have side effects and mutation if you need. Obviously the purists may view this as a negative, but being able to eg. just get a random number without going through a ton of hoops can make things a bit less frustrating - especially if you are unfamiliar with functional.
Once you have a good grasp of functional through ReasonML, Haskell will feel a lot less daunting.
when I started out to learn functional style programming I wanted to build a real project. I tried several languages out and I settled with F# because I just didn't like the enforced purity of Haskell and laziness as a default.
It just cost me so much time to constantly think about IO that I was barely figuring out what I wanted to write. It seemed impractical to me and now with some more experience I still think it is. Ocaml type languages strike a better balance in my opinion if you're interacting with the world.
I can assure you that, with practice, Haskell can be a very practical language. Having IO in the types lets one reason about where the effects are happening, which is especially important when trying to solve real world problems with functional techniques (i.e. transforming unreliable streams of data).
Because Reason fully supports imperative and OOP style. You don't need to use functional style if you don't want to (of course, aside from using other people's code). Here's some classic OOP:
class animal = {pub speak = "Animal noise";};
class cat = {inherit class animal; pub speak = "Meow!";};
class dog = {inherit class animal; pub speak = "Bark!";};
let speakTwice(animal: animal) = animal#speak ++ ", " ++ animal#speak;
print_endline(speakTwice(new dog)); /* Bark!, Bark! */
I guess it would be remiss to not mention that most Ocaml users shy away from the object oriented side of the language. Not because it's not well done (it is), but because modules work a lot better for many of the uses cases you'd want classes for.
You wouldn't choose it over haskell every time, but for the limited subset of times where you need to write frontend code ReasonML has distinct advantages.
ReasonML is basically OCaml that compiles to JS, designed to make interoperation with Javasascript easy. There are compile to JS projects for Haskell too, but the ease of interoperability with popular JS libraries like react and support from facebook's open source tooling chain make it a much better choice for most frontend projects IMHO -- unless you're already a haskell expert in which case go with what you already know!
That's not correct. What you've described is Bucklescript (which has OCaml syntax). ReasonML is an attempt to "improve" the OCaml syntax to something more familiar to folks coming from C-style family of lanauges. ReasonML can be used with both the Bucklescript compiler (which compiles to JS) -or- the standard OCaml one (which compiles to native).
While that is technically true, most people nowadays use them interchangeably especially because Reason is focusing so much on its web story, so I wouldn't expect people to make this distinction very often.
The frequency which this distinction is made in the general populace matters not in the least to me. What matters to me is reality/truth. Either people get on board with it or they butcher it. I have a bit more faith in them than you do it seems. Only time will tell which of us is correct.
You cannot go wrong by picking any statically typed functional language - Reason, Elm, F#, PureScript, Haskell, or even Idris. All of these languages share a similar style of programming that revolve around data that is described through a rich type system and program execution modelled as a series of pure functions that transforms values from one type to another.
For someone new to the Typed FP world though, Reason or Elm would be an easier starting point. Both communities are geared towards newcomers and have first-class support for front-end development.
My brief foray into Elm was very pleasant, and it is a community with great taste and aesthetics. Evan Czaplicki is wise beyond his age and is building a language that will last a long time. One reason why I would reach for ReasonML than Elm however is Reason's zero-overhead interop with Javascript. You can do this right in the middle of your code `[%%bs.raw console.log ("hey")];` and nobody will complain. This interop allows Reason to utilize the vast NPM ecosystem - so you can gradually adopt Reason in your front-end codebase. Your ReactReason code can use your plain React components and vice versa, and you can even use the bs-express library to write NodeJS applications with ExpressJS.
Elm aims to remain pure because it allows them to build a more solid ecosystem in the long run. It is a great choice as well, just that the shorter-term trade-offs make it slightly more difficult to work with existing Javascript code.
One angle in which Reason would be a better beginner language than Haskell is the number of concepts you have to understand before you can be truly productive with it. The shift from an imperative, dynamic world to a functional, statically typed world is already difficult enough. Reason/OCaml makes this transition easier because with it you can program in the familiar imperative style when you want, unlike Haskell where you need to rely on the elegant but takes-some-effort-to-grok Monads to tackle the Awkward Squad of I/O (https://www.microsoft.com/en-us/research/wp-content/uploads/...). And this might be controversial opinion - but the historical roots of Haskell as a language for bleeding-edge academic experimentation has lead to a certain kind of fragmentation that demands more effort from newcomers than a made-for-industry language would need. PureScript and Idris however have standardized on many of these things and might not share the same concerns. You still have to content with its laziness and purity. These are both practical and aesthetic choice in how to program, and they are very fun to explore. You just need to get started on some language in the statically typed FP camp to appreciate this long, deep rabbithole!
I'm looking for a language for cross-platform mobile app development using React/Expo. Can anyone give their opinion on ReasonReact vs Clojurescript Reframe?
I like the familiar syntax of ReasonML, but Clojurescript has LISP mojo and is more mature (more learning resources etc).
I don't know what the status of ClojureScript Reframe is, but there is an unofficial, in-progress ReasomML binding to Expo. You can contribute to that if you want https://github.com/fxfactorial/bs-expo (note that @fxfactorial, i.e. Edgar, works at Expo but is writing the Reason binding unofficially–for now at least).
The ReasonReact binding is high-quality and provides a lot of power (state management, routing) right out of the box. You can get started with that right now if you wish.