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

Syntax is what you deal with every time you read or write in any language. It can't be "the least important". It's probably one of the most important part when you _read_ the code, and reading the code is an important part of programming.

Just take a look at this:

    [1, 2; 3, 4]
is the same as:

    [(1, 2); (3, 4)]
That's just hard to read. I don't mind `;` being a separator, but tuples without parentheses is just annoying to look at in 9/10 places.


I agree the second form is preferable to the first one. But I think, most people will use the second form anyway. In my projects, ocamlformat chooses the second option.

In the case of OCaml, we can certainly find a few oddities, but really, I never found the OCaml syntax to be such an issue or to make me unproductive in any way. I'm much more prone to syntax errors in Haskell actually.

I suspect people who complain are mostly used to C-like syntax and aren't familiar with any language of the ML tradition. I agree that the barrier to entry would be lower if the syntax was more "mainstream", but I don't find there's really anything wrong with OCaml syntax, except that it's "different".


Oh, I don't think Ocaml syntax is an issue at all, I like most of it. I'm saying that, syntax isn't the least important part of a language - look at how many languages compile to JavaScript without bringing anything new ("new" being something like types in TypeScript).

> I suspect people who complain are mostly used to C-like syntax and aren't familiar with any language of the ML tradition

Yes, that's probably it. Can't really blame them - C, C++, Java, C#, PHP been very popular for long time. When I first saw Erlang, I thought it's a language for aliens.


There was a Revised Syntax (not sure if it's still a thing) which smooths out some of the most egregious warts. It requires preprocessing, but it was part of the standard distribution last I looked.

The most egregious for me was actually ;; being so close to ; to type and you'd be staring at weird type errors for ages before realizing what had gone wrong. I realize that this may be hard to convey to people who haven't used OCaml, but: The ;; terminates a top-level definition -- which was usually type-inferred when I was using OCaml... so it would lead to all sorts of "weird" type errors, when all that was missing was a simple ;

EDIT: Just for context, last looked (seriously) at OCaml ~15 years ago, last wrote it ~20+ years ago. It's cool, but it ended up just being my gateway drug to Haskell... for which I thank it :)




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

Search: