F# changes to OCaml
This question has been answered for some time now, but I was quite surprised that most of the answers say what OCaml features are missing in F# - this is definitely good to know if you want to port existing OCaml programs to F# (which is probably the motivation of most of the referenced articles). However, there are many features that make F# a different language (not just a limited version of OCaml for .NET!) Here is a couple of things that are added in F#:
- Units of measure that allow you to type-check code dealing with numerical calculations
- Meta-programming using quotations (which makes it possible to use LINQ in F# and is also essential for promissing projects like the WebSharper platform)
- Active patterns for creating abstractions for functional data types (and generally very useful feature for more complicated pattern matching applications)
- Computation expressions which is a language feature behing asynchronous workflows (a library for asynchronous I/O/web service/GUI programming)
- .NET compatible object-system that makes it possible to fully interoperate with the .NET platform (OCaml also has a support for objects but different - there are of course some benefits in both of the systems).
- Overloaded operators - As far as I know, OCaml doesn't have overloaded operators - in F# you can use
+for all numeric types as well as your types that support it.
And, honestly, I think that it is also worth mentioning the Visual Studio IDE. This is not a part of the language, but it really improves the user experience (IntelliSense support in Visual Studio is really good!)
If you look at the list, there are many things that largely contributed to the popularity of F#, so it's much more than just "OCaml without functors". F# is definitely based on OCaml (and takes ideas from other languages such as Haskell) and shares many aspects with them, however there is also a lot of other things. I guess that without things like asynchronous workflows, .NET style OO and meta-programming, the Microsoft Developer Division would never include F# in Visual Studio 2010.
F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.
F# and OCaml are taxonimically classes in the ML family of languages, which includes a whole passle of other weird animals too. F# is newer than OCaml, and it doesn't have either functors [functions of module -> module] or row types [object classes and polymorphic variants] yet. Between them, those two simplifications probably make the learning curve easier for someone developing on the .Net platform. Sadly, those two language features are hugely powerful in OCaml, so reading the OCaml literature to gain insights into how to code for F# will probably lead to premature frustration with the latter when it's probably an excellent alternative to C# where both are available.