OCaml is a hard sell for me. I want to really like it but everytime I start to play with it, I drift back to F#, .net core, service stack, and all the other open source projects are really hard to compete with. The Syntax is similar to OCaml (really really close IMO) and other then it's ties to Microsoft it's seems to be all upside with F#. Is there a compelling lib or advantage of OCaml over f#?
OCaml has cool stuff like MirageOS, as one compelling lib (still a research project). It's a library that constructs unikernels. You write your application, build it, and out comes a VM that you can run.
I feel that many of the advantages of switching to OCaml are minimised when you are already using an ML!
Soon, there should be a compelling performance case for using OCaml. There are rumours that in the next release, there'll be an MLton type whole program optimisation setup, which should reduce the cost of abstraction to zero.
MirageOS is more than just a research project. It's deployed in the wild by folks who weren't active researchers. I'd certainly call it an open-source project in its own right.
Functors tend to be the big thing that's missing, right? F# just had to drop the feature because of compatibility with .Net packages, as I understand, but it severely cripples the module system.
MLs are such that the value-level stuff and the module-level stuff are more or less independent. So you can go a long way just liking the value-level stuff without really caring about the status of the module-level stuff. But it's also a pretty big motivator for the design of ML. F# is at least weirdly missing out here.
"a redesign of ML in which modules are truly first-class values, and core and module layer are unified into one language. In this "1ML", functions, functors, and even type constructors are one and the same construct; likewise, no distinction is made between structures, records, or tuples."
Sure. I'm not super familiar with F#, but I can state things which depend upon functors.
A good example is the Set.Make functor in the OCaml stdlib. Elements in a Set must be orderable for efficiency's sake, so to construct a Set you parameterize it over a module specifying not only the type but also its ordering.
module type Set = sig
module type OrderedType =
sig
type t
val compare : t -> t -> int
end
module type S =
sig
type elt
type t
val empty : t
(* ... *)
end
module Make :
functor (Ord : OrderedType) -> S
with type elt = Ord.t
end
Here the OrderedType module signature represents any type that also has an ordering. The S signature represents the result signature of calling the Make functor which is passed any OrderedType-substantiating module and uses it to construct the (Set.S with type elt = Ord.t) module.
> Is there a compelling lib or advantage of OCaml over F#?
Maybe not for folks whose primary platform in Windows? The .NET stack is the primary advantage there, no?
For those of us on Linux, IMO OCaml is the similar language with complete platform support. I know .NET core is now available, but some time will have to pass to know if Microsoft's support for .NET on Linux is a long term plan.