What is F#?

These pages document F# as a research project. You can find out all about the latest happenings with F# at the MSDN F# Developer Center.

F# is a typed functional programming language for the .NET Framework. It combines the succinctness, expressivity, and compositionality of typed functional programming with the runtime support, libraries, interoperability, tools and object model of .NET. F# stems from the ML family of languages and has a core language compatible with that of OCaml, though also draws from C# and Haskell. F# was designed from the ground up to be a first-class citizen on .NET, giving smooth interoperability with other .NET languages. For example, C# and F# can call each other directly. This means that F# has immediate access to all the .NET Framework APIs, including, for example, Windows Presentation Foundation and DirectX. Similarly, libraries developed in F# may be used from other .NET languages.

Since F# and OCaml share a similar core language, some OCaml libraries and applications can cross-compile either directly or with minor conditionally-compiled changes. This provides a path to cross-compile and/or port existing OCaml code to .NET, and also allows programmers to transfer skills between these languages. A major focus of the project has been to extend the reach of OCaml-like languages into arenas where they have not traditionally been used. Throughout the project the designers of F# are grateful for the support and encouragement of Xavier Leroy and others in the OCaml community.

F# As a Language:

  • F# includes support for the foundational features of functional programming including tuples, lists, options, function values, local function definitions, pattern matching and sequence expressions.

  • The powerful type inference mechanisms of F# allow code to be both succinct and yet fully type-checked.

  • F# also includes support for advanced functional programming constructs such as active patterns and computation expressions. Computation expressions can be used to express data queries and client/server modalities in AJAX-style web programming. They enable programmers to write succinct and robust reactive agents through the use of asynchronous workflows. Computation expressions are related to ``monads'' in Haskell.

  • F# embraces object-oriented programming and includes support for type-inferred, succinct descriptions of object types.

  • F# allows types and values in an F# program to be accessed from other .NET languages in a predictable and friendly way.

  • F# includes support for a form of meta-programming, inspired by LINQ. This allows data queries to be expressed and type-checked in F# code and then dynamically compiled and translated to target languages such as SQL using the LinqToSql framework.

  • F# fully supports .NET generics and the language was designed partly with this in mind.

  • Through .NET, F# supports advanced language and runtime features such as Unicode strings, dynamic linking, preemptive multithreading, and SMP support.

F# for Developers:

  • The F# Interactive environment fsi.exe supports top-level development and exploration of the dynamics of your code and environment.

  • The command line compiler fsc.exe supports separate compilation, debug information and optimization.

  • F# comes with F# for Visual Studio, an extension to Visual Studio 2005 that supports features such as an integrated build/debug environment, graphical debugging, interactive syntax highlighting, parsing and typechecking, IntelliSense, CodeSense, MethodTips and a project system.

  • F# can be used with tools from the .NET Framework, Microsoft's Visual Studio and many other .NET development tools. 

  • F# comes with an ML compatibility library that approximates the OCaml 3.06 libraries. This means you don't have to use .NET libraries if it is not appropriate.  It is possible to write large and sophisticated applications that can be cross-compiled as OCaml code or F# code, and we take this mode of use seriously.