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…
OCaml Syntax Sucks (2016)
111–120 of 140 posts
Re: OCaml Syntax Sucks (2016)
#112As 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?
Re: OCaml Syntax Sucks (2016)
#113My OCaml is very rusty, but just add some parentheses, no?
Re: OCaml Syntax Sucks (2016)
#114Earlier 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.
Re: OCaml Syntax Sucks (2016)
#115Weak 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.
Re: OCaml Syntax Sucks (2016)
#116Earlier 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..…
Re: OCaml Syntax Sucks (2016)
#117Earlier 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
Case fallthrough almost always ends in tears.
Re: OCaml Syntax Sucks (2016)
#118Earlier 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.
Re: OCaml Syntax Sucks (2016)
#119Another 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)
#120Earlier 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.
(also: generally speaking the "core" of .NET is quite unlike most other products Microsoft puts out, so chances are you will be pleasantly surprised)