Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know why they felt they had to mess with OCaml's syntax - one of the nicest around AFAIC. With F#, even MS didn't feel like they had to add extra braces and other baggage and change keywords ("match" to "switch ()", etc.) to make C# programmers have an easier first ten minutes of transition time.


I think F# cleaned up a lot of OCaml’s syntactic oddities nicely, though I could do without the off-side rule.


F# supports OCaml syntax as well, via a compiler pragma.


f# has diverged away from ocaml enough that the small fact that a tiny subset of it is compatible with ocaml is just a trivia fact.


I’m aware. #light “off”


Agreed! and the approach to operator overloading is much more pragmatic.


I think Haskell's or F#'s syntax is a lot better, OCaml has a lot of edge cases that require parens. OCaml is an old language and it really shows in the syntax. I personally think Reason's cleanup of strange parsing rules that OCaml has is a good step forward, though changing match to switch is kind of annoying, I must admit.


There's a few legitimate issues with OCaml syntax that have been fixed by Reason at least. E.g. `match`/`if` not having an `end` means you need to use parens or `begin`/`end` to nest match and have ; inside of an `if` body. There's also some ambiguity between functional `if` and imperative `if` in some situations.


Despite that, Reason adds semicolons and braces to OCaml; presumably this was to make it have a more JavaScript aesthetic for on-boarding (ignoring JS's ASI)?


Explicit opening and closing structures help locate and explain errors better.

In an absence of an entirely obvious, unambiguous, commonly known way of formatting, it's helpful.


I'm not sure to understand how it helps. Are you talking about parsing errors ?

As for formatting, if you manage to get an AST, what would be made easier by braces ?


Yes, parsing errors. In a number of cases you can legitimately continue to interpret a text well past the missing closing token, and signal an error in a place which does not seem related.

If you already have a correct AST, you can render it whatever way you want.


Because OCaml aware editors/IDE don't exist.


Merlin works really well in my experience for both ReasonML and OCaml. Also there's LSP support so OCaml/ReasonML have as much editor support as any other language.


I was being sarcastic....


Are you referring to Reason? I don't see anything related to messing OCaml syntax in the OP.


"Reason, also known as ReasonML, is a syntax extension and toolchain for OCaml created by Jordan Walke at Facebook.[2] Reason offers a syntax familiar to JavaScript programmers, and transpiles to OCaml.[3]"

https://en.wikipedia.org/wiki/Reason_(syntax_extension_for_O...


got it, I was just confused since usually top level comments refer to the original post, which in this case is a Textbook for OCaml that doesn't mention Reason anywhere afaict


Sorry, my bad - I meant to reply to @melling, not the top-level


Well, with F# they did change some significant things e.g. type parameter syntax. Anyway, the point of Reason is that some people just won't even look at OCaml syntax. They just won't, that's the way it is. Reason allows us to onboard those people now, get them to see the benefits of the language, and perhaps later even come around to preferring the OCaml syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: