Tech Brief
Microsoft's F# Functional Language
A functional programming language built for the .NET Framework
Functional programming is a coding style that emphasizes ideas such as composition from simple building blocks, immutability of data structures and the use of functions as data. In recent years, ideas from functional languages have been incorporated into many parts of Microsoft's developer tools, from generics in .NET Framework 2.0 to lambdas in C# 3.0. In addition, technologies such as Language Integrated Query (LINQ) and Parallel Extensions for the .NET Framework have applied functional programming techniques toward key software development challenges.
Last October, Microsoft announced the F# programming language will join the collection of .NET languages delivered by its Developer Division. F# is a functional programming language that also embraces imperative and object-oriented programming (OOP) concepts. Originally designed and developed by Don Syme in Microsoft Research's labs in Cambridge, England, F# draws from other functional languages, notably LISP, Haskell and ML-derivative OCaml.
F# as a Language
As a typed functional programming language for the .NET Framework, F# 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 functional languages and has a core language compatible with that of OCaml, though it also draws from other languages such as C#. F# was designed by Syme from the ground up to be a first-class citizen on .NET, giving it 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. Similarly, libraries developed in F# may be used from other .NET languages.
One of F#'s most striking features -- inherited from the ML family of languages -- is its powerful type inference. This allows F# code to contain few type annotations, making it concise like code in dynamic languages such as Python and Ruby, while maintaining the same type-correctness guarantees and performance provided by languages like C# and Java.
For more advanced developers, F# includes some powerful functional language constructs such as Active Patterns, Workflows and Quotations.
Interest in F# has come from a few different areas of the software development spectrum. The increasing awareness of functional programming beyond academia has fueled a particular interest in F#. The .NET language provides an easy introduction to functional programming techniques, without losing access to the imperative and OOP features familiar to many developers. Microsoft is also seeing a strong interest in F# from the financial, scientific and technical computing sectors. The language has syntax and primitives that are more natural to these domains, and it offers a focus on experimentation and data-manipulation through an interactive environment.
Many computer science departments teach functional programming languages in their curriculums. F# provides an attractive option for these courses and offers an easy transition to or from other courses that use languages like C#.
Learning More About F#
Releases of F# from Microsoft Research are available at http://research.microsoft.com/fsharp. These releases include a plug-in for Visual Studio 2005 and VS 2008 that provides syntax highlighting and background error reporting for F# code. Expect to see future releases of F# from the Microsoft Developer Division with improved VS integration and bug fixes.
For more info about F#, visit the F# community forums at
http://cs.hubfs.net, and Don Syme's blog at
http://blogs.msdn.com/dsyme.
About the Author
Luke Hoban is the program manager for F# at Microsoft.