It's easy to get a quick comparison by searching stackoverflow so I won't reitterate those answers, but I would just mention a couple of my favorite things from OCaml that F# doesn't have that those answers tend to leave out:
- Polymorphic variants
- GADTs
- Named arguments (that are still curried if you can believe it!)
- Last time I checked OCaml had better record label scoping. F# doesn't allow two record types in scope that share a record label name. Does anyone know if F# has plans to implement what OCaml has (or have they already?) OCaml used to have the same problem but it was fixed and now dealing with OCaml records has been massively improved as a result.
I'm mostly only experienced with F#, but it has a few features that OCaml doesn't (type providers, units of measure, computation expressions) and is missing a few that OCaml has (functors). F# has a bit of a cleaner syntax in some ways IMO[0], but that's offset by .NET interop - the standard libraries are pretty much all borrowed from C#, and therefore tend to be more OO-first than functional-first.
Also, because it runs on .NET/Mono, you can do multicore stuff in F# very easily, whereas OCaml's multicore support is very immature (and actually not present at all until the next release, 4.03).
I would not actually compare them from language point of view but ecosystem point of view - but then again, I like simplistic stuff. Give me algebraic datatypes, pattern matching and type inference and I'm happy.
That said, F# in my opinion benefits hugely from the Visual Studio tooling (if one can use it). The main benefits for me are:
- the integrated F# command line facilitates pretty much similar development as with lisps - one can instantiate a context, and then develop ones program code at the same time as the context is live. With static types. I.e. create a function, interpret in repl, run function, observe the side-effects etc. Once done compile. Then load dll in repl, build new functionality on top of previous module etc etc.
- Visual Studio intellisense debugs my logic as I type it. Having the IDE proofreading my sources as I type it is a huge productivity win. Of course, if the program logic is built around types, that is - but with F# this is the easiest way to write stuff any way.
- This is a fringe issue but one can write Unity scripts in F# :)
> the integrated F# command line facilitates pretty much similar development as with lisps
OCaml has Utop, and that's a pleasure to work with.
> Visual Studio intellisense debugs my logic as I type it. Having the IDE proofreading my sources as I type it is a huge productivity win. Of course, if the program logic is built around types, that is - but with F# this is the easiest way to write stuff any way.
You can use Merlin to do the same thing in vim or emacs. This doesn't grant you the rest of IDE features, but you still get typechecking, you can check the type of a variable, and you get intelligent renaming (within the same file).
- Polymorphic variants
- GADTs
- Named arguments (that are still curried if you can believe it!)
- Last time I checked OCaml had better record label scoping. F# doesn't allow two record types in scope that share a record label name. Does anyone know if F# has plans to implement what OCaml has (or have they already?) OCaml used to have the same problem but it was fixed and now dealing with OCaml records has been massively improved as a result.