7 ms·
Why should someone unfamiliar with functional style programming be learning ReasonML rather than say, something like, haskell? Looking for concrete, technical a
by nafizh 9y ago
Why should someone unfamiliar with functional style programming be learning ReasonML rather than say, something like, haskell? Looking for concrete, technical answers.
- duckfruit 9y agoYou 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!
- aassddffasdf 9y agoThat'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).
- yawaramin 9y agoWhile 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.
- aassddffasdf 9y agoThe 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.
- Barrin92 9y agowhen 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.
- willtim 9y agoI 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).
- jasim 9y agoYou 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/2016/07/mark.pdf 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!
- weavie 9y agoHaskell 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.
- chillee 9y agoI 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. #3. Less productive in practice. For example, long build times are a huge problem in practice. See https://www.reddit.com/r/haskell/comments/45q90s/is_anything_being_done_to_remedy_the_soul/ https://www.reddit.com/r/haskell/comments/45q90s/is_anything... 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.
- chillee 9y agoI 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.
- tome 9y ago> 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". http://augustss.blogspot.co.uk/2011/05/more-points-for-lazy-evaluation-in.html http://augustss.blogspot.co.uk/2011/05/more-points-for-lazy-...
- chillee 9y agoI was basing off of this CUFP report regarding Standard Chartered's use of Haskell. http://anil.recoil.org/papers/2011-cufp-scribe-preprint.pdf http://anil.recoil.org/papers/2011-cufp-scribe-preprint.pdf > 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.
- yawaramin 9y agoBecause 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! */
- chillee 9y agoI 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.
- pjmlp 9y agoYeah, mainly because in most OOP languages, classes/interfaces are just a kind of glorified modules anyway.