Live data from Hacker News

OCaml Syntax Sucks (2016)

xahlee.info

81–90 of 140 posts

Re: OCaml Syntax Sucks (2016)

#83
Another thing I personally hate about OCaml's syntax is the order of generic parameters being backwards. I know why it's like that, but it still doesn't make any sense to me both as a programmer and as a non-native english speaker.

Re: OCaml Syntax Sucks (2016)

#84
post #19

I want to like OCaml, but the tooling isn't great and async operations require a library to work for some reason. I tried f# but if you want to do async operations there, you have to do them in these even weirder "computation blocks" with this annoying ! Syntax. I've found that the best way to write ML family programs is to let an imperative language handle IO and then write any more mathematically or logically compl…

You might like Scala. It has much of the good parts of OCaml or F#, but also lets you write imperative code freely when you want. The `for`/`yield` syntax for async is very nice IMO, or you can write Javascript-like promise chaining directly if you want.

Scala is great, nearly all of its constructs were right and right early. Kotlin/Java catching up before it got popular kinda nixed its growth and at this point i dont see it being chosen for new projects.

Gleams a nice one too if you want pure functional, small community though.

Re: OCaml Syntax Sucks (2016)

#85

Earlier quoted context omitted.

2. In general there aren’t a ton of punctuation characters that are very common, which is great for typing ergonomics. Don’t get me wrong, there are still a lot of symbols, but I feel compared to some languages such as Rust, they’re used a lot less. I never really seen someone put that into words. I always feel a certain kind of weird when I look at a language with tons of punctuation (Typescript is good example).

I think typing ergonomics are overlooked as well. CSS has the most verbose syntax for variables I've had to use regularly e.g. `var(--primary-color)` which I find unpleasant to type when experimenting. And I actually like the lack of brackets and commas in OCaml for function e.g. you write `add_numbers 1 2` instead of `add_numbers(1, 2)`. Brackets and commas in particular require you to navigate left/right a lot to a…

Tangentially there is room for optimizing for non-american keyboards.

The accent grave (backtick) you're using in a Markdown-inspired way is utterly annoying to type on keyboards where accents are implemented as dead keys, to be combined with vowels, common on european keyboard layouts. For your example I had to type `, but then look ahead to the a of add_numbers and remember to put in an extra space, so that the ` and the "a" don't combine to an "à".

Also I find it somewhat illogical: The usage of an accent as a character in itself in programming languages is one of my pet peeves. Just being an ASCII character is not reason good enough to keep using it.

Curly or square brackets, backslashes and other stuff also put you into uncomfortable AltGr or Cmd-Shift territory on some keyboards. American language designers are often blind for these simple ergonomics.

Re: OCaml Syntax Sucks (2016)

#86
I tried out OCaml last year for solving the AOC puzzles. I managed to solve all of them in earlier years using Haskell or Scala, but this was the first time I gave up. It was not as much the syntax, it was the schism between the OCaml standard libraries and those from Jane Street that turned me off. Whatever I was searching for on the Internet, resulted in a mix of links to either of those libraries. It was confusing and very frustrating.

Re: OCaml Syntax Sucks (2016)

#87

I 100% agree. The lack of clear scoping and function call grouping syntax just turns it into a word soup. It becomes difficult to parse for humans and I spend a stupid amount of time just getting the semicolons, begin/ends, etc. right. It's like... when you mismatch brackets or braces in a C-style language, except to resolve the problem you can't just find the bracket that's highlighted in red and count; you have to…

Use ocamlformat and set "profile = janestreet"

Re: OCaml Syntax Sucks (2016)

#88

I tried out OCaml last year for solving the AOC puzzles. I managed to solve all of them in earlier years using Haskell or Scala, but this was the first time I gave up. It was not as much the syntax, it was the schism between the OCaml standard libraries and those from Jane Street that turned me off. Whatever I was searching for on the Internet, resulted in a mix of links to either of those libraries. It was confusing…

I get that. Having read Real World OCaml back when it was an O'Reilly book, I had a hard time not thinking Core was the defacto OCaml std lib. And its horrible documentation made me think the OCaml community was dead - or at least brain-dead. It appealed to one type of learner: Someone who just needs to see type signatures and has no interest in examples of how it could be used.

After reading OCaml From The Very Beginning my stance softened. Learning PURE OCaml is a must. (if you want to do AoC with it). You may find yourself bringing in Core or Base, after you've got a good idea of a solution.

It's definitely a fun language for doing AoC... but it can become extraordinarily frustrating when you hit a wall and all the StackOverflow answers assume Core.

Re: OCaml Syntax Sucks (2016)

#89
post #46
post #14

Earlier quoted context omitted.

Depends on what you compare it with, I guess. (I worked in OCaml and Haskell and other 'weird' languages professionally in different jobs for many years.)

Fsharp is pretty good in teams f tooling at least when compared to other functional languages

Although I'm not a Microsoft fan, their docs for F# are worlds ahead of anything I've seen for OCaml (I know a few OCaml folks are working to fix this).

I've considered trying it for Advent of Code this year.

Re: OCaml Syntax Sucks (2016)

#90
post #81

There’s indeed something wrong with a syntax that needs double semicolons all over the place.

It doesn't. They are useful for the REPL only, to tell it that a statement is over. I prefer this over what Python does, which is to consider that an empty line is the end of a statement. Copy-pasting functions from a file to the REPL can be a bit tedious because of this. In OCaml, all I have to do is to add ;;, and I'm good to go.
Post reply on HN