1. 15
  1. 7

    This is a chance to get familiar with a newer and exciting language in the compile to Javascript world.

    Why Reason is always marketed as “language that compiles to javascript”? I thought it’s just alternative syntax for Ocaml (i.e. it rather compiles to Ocaml or its internal representation than JS), and that compilation to javascript is performed by Bucklescript, not Reason.

    What js-specific functionality it has, compared to plain Ocaml with Bucklescript? Maybe better integration with npm mentioned on website? Or [% … ] quasi-quotations allowing to embed raw js?

    Even Bucklescript website shows code examples in Reason. I’m confused.

    1. 5

      ReasonML is both a syntax and a default build chain relying on Bucklescript. You can use the syntax rewriter to build normal, binary libraries and executables via ocamlc and your build tool of choice.

      Bucklescript heavily integrates with the Javascript runtime - depending on your needs, you can cast directly between a javascript object and a type safe OCaml value. This is why ReasonML uses Bucklescript as the compiler: it makes it much easier to interop with existing JS. Compare to js_of_ocaml which compiles the OCaml runtime to JS (more or less) and makes no attempt to reconcile the difference.

      The only feature specific to ReasonML is the JSX rewriter (AFAIK) - that only works on ReasonML source, not OCaml.

      OCaml + Bucklescript + npm = (default ReasonML toolchain) - jsx

      1. 2

        Most tooling and libraries seem to build on the nodejs side of the ecosystem, meaning npm packages instead of opam, build scripts which only address javascript output, no native binaries.

        (I only glance over ReasonML documentation from time to time, not an active user)

      2. 1

        I must have missed where in this video ReasonML, the language, is actually introduced. Double-click a Visual Studio plugin aaaaaand… continued in the next, as yet unreleased, video?

        1. 2

          If you’re interested in more: