1. 51

  2. 9

    repeating my comment from reddit, i was prepared to see this as yet another attempt at ml with a c/javascript syntax (opa, haxe and rust all do this to various extents), but this seems like a very well-thought-out set of changes by people who actually like mlish syntax on the whole but want to fix some of the warts. i’m impressed.

    1. 3

      Correct me if i’m wrong but, Haxe felt more like a better version of actionscript with an ocaml compiler versus an ocaml inspired language.

      1. 3

        that’s a fair point; i discovered haxe after ocaml and never used actionscript, so i tended to take more notice of the bits that resembled ocaml. mythryl would be a better example of an explicitly C-like syntax for an ml.

    2. 4

      Reason : OCaml :: CoffeeScript : JavaScript ? But, from a quick glance at the syntax changes, it doesn’t seem to add much but some “simplicity”. Maybe that’s a good thing, but OCaml, and it’s syntax is already incredibly simple by many regards…

      1. 3

        it adds consistency more than simplicity. i’m not sure why the change from -> to => (not really a fan of that, on trivial aesthetic grounds), but everything else fixes definite warts in the existing syntax.

        1. 4

          isn’t -> a type-level operator? I think for clarity issues it makes sense to split type-level operators -> and expression-level operators => so they are definitively separate.

          Haskell’s [a] being both an expression and a type was something that tripped me up early, the same kind-of applies to (a,b) being both an expression and a type.

          Now, on the other hand, I like Idris, where there are a whole lot of these things that are type-level or expression-level which have the same syntax because they are the same thing. This is neat and super useful :D

          1. 1

            they’ve been unifying syntax elsewhere - e.g.

            type person = {name: string, age: int};
            let somePerson = {name: "Guy", age: 30};
            let {name: n, age: a} = somePerson;
            1. 1


      2. 4

        This page might be useful for those of you who already know OCaml: Reason and OCaml: A quick reference for OCaml Programmers

        1. 3

          I’m not an OCaml programmer, so much as a motivated dabbler, but I can’t find much to object to in the Reason syntax changes.

          1. 9

            Most of them are quite nice. Re-appropriating = for mutable field changes instead of equality is pretty stupid, and replacing match with switch is silly, but whatever. Overall the greater consistency is a win; I remember being very frustrated with OCaml trying to guess where I needed to keep spamming more parens to get the parser to understand what I meant.

            1. [Comment removed by author]

              1. 4

                Ugh. Pandering indeed!

                Explicit syntax for mutable variables is a feature!

            2. 2

              OCaml already has a second syntax aimed at ironning out the kinks in the original - the so-called “revised syntax”. http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html

              The general consensus seems to be that while revised syntax is a little better, having two different syntaxes isn’t worth the gains. Seems like this fragmentation will be similar.

              That being said, ML would be a great language choice for many programmers/tasks. I’m thrilled to see it in wider use.

          2. 3

            I work quite a bit in F#, which I think solves some of the operator precedence issues. I think I’ve gotten used to the F# syntax pretty well, but I know Reason would go over like wildfire on my team. crosses fingers

            1. 3

              I get the sense that the team that made this workshopped it with actual people who weren’t already familiar with ML before releasing it. Probably with Facebook employees. I like that a lot.

              1. 1

                It’s better than guessing.

              2. 1

                Why the c/javascript syntax? I find curly braces to be noise. Here’s an experiment if you like curly braces: why don’t you just left justify all your code? Syntactic white space, as in F#, is much cleaner. And the light syntax option in F# (which almost everyone uses) cleans up the other unpleasantness (in) of OCaml syntax.

                I skimmed through the docs pretty fast so I may have missed this: is their no tail recursion?

                1. 2

                  this is not a new language, it’s just a new syntax for ocaml. so it definitely has tail recursion because ocaml has tail recursion.

                  1. 2

                    I was just struck that the rec keyword was not in the docs, as they saw fit to document let.