3 ms·
Ocaml is a mess. Just like C++, PHP, or Perl, it's spent way too much time bolting extra stuff here and there until different codebases can look like completely
by hajile 9y ago
Ocaml is a mess. Just like C++, PHP, or Perl, it's spent way too much time bolting extra stuff here and there until different codebases can look like completely different languages. Ocaml's features don't flow well together and make it very hard to teach the language (as used in the real world) to new developers.
Golang has fewer features than Ocaml and is worse in almost every way, but people love it's simplicity. The best language features are the ones you can add without significantly increasing syntactic complexity.
I agree that Ocaml has some great features that the current SML spec lacks. That spec is 20 years old now. There's plenty of room to look at Ocaml features and pick a good set that does enough of the things without blowing up the complexity.
SML's let expression is definitely superior to Ocaml's. Ocaml has two different `let` expressions -- one for top-level and one for sub-expressions.
To borrow from a comparison [here](http://adam.chlipala.net/mlcomp/ http://adam.chlipala.net/mlcomp/)
(* Ocaml *)
let six = 6
let rec fact x = if x = 0 then 1 else x * fact (x - 1)
let six_fact =
let six = 6 in
let rec fact x = if x = 0 then 1 else x * fact (x - 1) in
fact 6
(* SML *)
val six = 6
fun fact x = if x = 0 then 1 else x * fact (x - 1)
val six_fact =
let
val six = 6
fun fact x = if x = 0 then 1 else x * fact (x - 1)
in
fact 6
end
SML groups multiple declarations together which provides greater clarity IMO while having an end keyword helps identify the let block.
- ernst_klim 9y ago>Ocaml's features don't flow well together May you provide an example of features which don't flow well together?