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.

Programming in F#
[click image for larger view]
Programming in F#

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#.

A Taste of F#
[click image for larger view]
A Taste of F#

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.

comments powered by Disqus

Featured

  • Uno Platform Ports Windows Calculator to Linux

    Uno Platform has ported the famed Windows Calculator, open sourced last year, to Linux as part of a continuing "proof point" effort to demonstrate the reach of what it describes as the sole UI offering available to target Windows, WebAssembly, iOS, macOS, Android and Linux with single-codebase applications coded in C# and XAML.

  • ASP.NET Core OData 8 Preview Supports .NET 5, but with Breaking Changes

    ASP.NET Core OData, which debuted in July 2018, is out in a v8.0 preview that for the first time supports the upcoming .NET 5 milestone release.

  • VS Code Java Team Details 5 Best Dev Practices

    Microsoft's Visual Studio Code team for Java development added a new Coding Pack for Java installer and detailed best practices for setting up a development environment.

  • Binary Classification Using PyTorch: Defining a Network

    Dr. James McCaffrey of Microsoft Research tackles how to define a network in the second of a series of four articles that present a complete end-to-end production-quality example of binary classification using a PyTorch neural network, including a full Python code sample and data files.

  • Blazor Debugging Boosted in .NET 5 RC 2

    In highlighting updates to ASP.NET Core in the just-launched second and final Release Candidate of .NET 5, Microsoft pointed out better debugging for Blazor, the red-hot project that allows for C# coding of web projects.

Upcoming Events