*
Quick Links|Home|Worldwide
Microsoft*
Search for


F# compared with OCaml

F# contains is similar in many ways to the OCaml language. However, there are some important differences, even for the core language, though mostly arising from essentially unavoidable changes for the design of a .NET language.  The differences small enough that the F# compiler can be compiled as OCaml code, or can compile itself as F# code.

For a detailed description of the ways in which F# is incompatible with OCaml please see the F# Manual. The table below will act as a guide to those features found in ML languages that are supported by F#.

Feature

F#

OCaml

Unicode strings and wide chars

Yes

 

Functions as values

Yes

Yes

Discriminated unions

Yes

Yes

Generics/
Type parameters

Yes

Yes

"Interior" bindings

Yes

Yes

Records

Yes

Yes

Pattern matching

Yes

Yes

Type aliases

Yes

Yes

Modules

Yes

Yes

Module Signatures

Yes

Yes

Nested Modules

Yes

Yes

Namespaces

Yes

 

Strong-named assemblies

Yes

 

Inheritance (authoring)

Yes

Yes

Object expressions

Yes

Yes

Structural subtyping constraints

 

Yes

Nominal subtyping constraints

Yes

 

Structured classes

 

Yes

Variance on type parameters

 

Yes

Labelled Arguments

 

Yes

Default parameters

 

Yes

"Printf" style formatting

Yes

Yes

Operator Overloading

Yes

 

Functors

 

Yes

The "platform" features (things that often differ between ML dialects) are:

Feature

F#

OCaml

Structural equality

Yes

Yes

Reference equality

Yes

Yes

Structural hashing

Yes

Yes

Polymorphic serialization/deserialization

Yes

Yes

Cross-module recursion

 

 

C Foreign Function Interface

Via C#

Yes

COM interopability

Via tlbimp.exe

Via camlidl

.NET interopability

Yes

 






©2008 Microsoft Corporation. All rights reserved. Terms of Use |Trademarks |Privacy Statement