Live data from Hacker News

OCaml Syntax Sucks (2016)

xahlee.info

111–120 of 140 posts

Re: OCaml Syntax Sucks (2016)

#111

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 Begi…

Yup the thing that people recommending Jane Street libraries to newcomers don't realize is that they are made by and for a well-established team of OCaml developers who have been extensively trained in how to use it in Jane Street. Outside of the warm protective bubble of Jane Street's tribal knowledge, it's a more difficult task to pick up and understand their libraries with their often minimalistic documentation.

Re: OCaml Syntax Sucks (2016)

#112

As a matter of policy can HN please not accept submissions with non-https URLs? It's a checkbox at most web hosts, built in to many reverse proxies, etc. There's no excuse for not offering htttps, particularly since it places users at risk if at any point along the path between them and you, there's someone untrustworthy.

> places users at risk Help me out here, what's the threat model here while reading troll programming blogs?

https://doesmysiteneedhttps.com/

Re: OCaml Syntax Sucks (2016)

#114

Earlier quoted context omitted.

And for people who don't like writing so many 'in's, we also have 'and': let x = 1 and y = 2 and z = 3 in x * y * z Which indicates that the binding of y can't refer to x and so on.

I've written a lot of OCaml and I always thought `let .. and .. in` indicated that the definitions were mutually recursive and that you could refer to y in x, like in `let rec .. and` or `type .. and`! That's surprising.

I never thought about it much before but after seeing let+ and and+ 'debut' as operators for applicative functors (ie parallel application) it sort of clicked for me then.

Re: OCaml Syntax Sucks (2016)

#115

Weak arguments in the article with badly chosen examples. If one wanted to criticize OCaml syntax, the need for .mli-files (with different syntax for function signatures) and the rather clunky module/signature syntax would be better candidates.

The problem with mli files and counter-argument to “they’re good documentation” is that, with a few visibility annotations (`pub let`, etc.) they could be auto-generated. Then you don’t have to write your entire public interface twice (sans the inferred `let` types, but I already prefer to make those explicit in the `ml` because otherwise you get much more verbose type errors when they don’t align with the `mli`).

Re: OCaml Syntax Sucks (2016)

#116
post #96

Earlier quoted context omitted.

> The title is a little inflammatory. Xah Lee is not exactly known for moderation. If you’re not familiar, browsing the site may be worth your while. It’s full of inflammatory and sometimes bizarre takes, but I’d be hard pressed to argue that it’s ill informed.

> If you’re not familiar, browsing the site may be worth your while Not inclined to do this though, his site doesn't exactly seem easy to browse either. Maybe a reflection of his bizarre takes? Do you have some examples of well-informed articles by him? I found one about "syntax vs semantics" that seems as inflammatory and ill-informed as TFA under discussion here. I'm not inclined to give this person much leniency..…

He has Mac keybindings for the most rational home row key navigation scheme: http://xahlee.info/kbd/osx_keybinding.html

Re: OCaml Syntax Sucks (2016)

#117

Earlier quoted context omitted.

Totally agree. In particular when I read #2 I was really scratching my head. It's a functional language - the thing on the left of the equals sign is a pattern. Apart from the argument you pass, patterns for functions look similar to patterns for constants precisely because in a functional language everything looks like a function. And everything looks like a function because just about everything is a function. The…

> ...(C, bourne shell, etc etc) have this exact same problem... Doesn't Bourne shell syntax have terminator keywords for all control flow structures? https://unix.stackexchange.com/a/256152

It does (so you have esac to end a case statement in this case) but depending on what combination of line noise (;& vs ;;) you use, you have case fallthrough like c. You have to sort of want to do it (ie ;& isn't very common) but it does happen.

Case fallthrough almost always ends in tears.

Re: OCaml Syntax Sucks (2016)

#118
post #97
post #12

Earlier quoted context omitted.

Fortunately, the OCaml compiler is very modular, and there have been efforts to make things more... reasonable. - Reason, a different syntactic frontend for regular OCaml: https://reasonml.github.io/ - ReScript, a language with OCaml semantics that compiles into: JS https://rescript-lang.org/ (I suppose it's a reincarnation of js-of-ocaml).

Worth nothing that the former lead dev of ReScript left to create a WASM-first language call Moonbit ( https://www.moonbitlang.com/ ). The language design is awesome and corrects a lot of the corners that they just couldn't get around in OCAML. A touch early, but really well done.

Thanks, I didnt know about Moonbitlang.

Re: OCaml Syntax Sucks (2016)

#119

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.

[deleted]

Re: OCaml Syntax Sucks (2016)

#120
post #46

Earlier quoted context omitted.

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.

Please give it a try! And perhaps it catches your eye enough - it could use contributors too.

(also: generally speaking the "core" of .NET is quite unlike most other products Microsoft puts out, so chances are you will be pleasantly surprised)

Post reply on HN