- OCaml's pattern matching is more powerful (more or-patterns, lazy, matching records with field-puning): `match x with lazy {x; y; z=(None | Some 0); _} -> x+y`
- GADTs along with phantom types: many things are now type-safe (including the builtin format strings)
- inline records in sum types: `type 'a tree = Empty | Node of { left: 'a tree; mutable key: 'a; right: 'a tree; }`
also, I prefer `let x = y in …` rather than SML's equivalent which forces nesting because of the final `end`.
In addition, flambda generates very good code. I don't know if it's as good as MLTon, but it's definitely an improvement.
(edit: formatting)
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/)
(* 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.May you provide an example of features which don't flow well together?
SML also has a multithreaded implementation in polyml and a better compiler in mlton. The standard library is not big enough, but at least there aren't 4 like in ocaml (std, core, batteries, and container).
The only issue is that just a little more syntax would be nice, but the next gen group is working on that.