Channels ▼
RSS

.NET

F#: Putting the 'Fun' into 'Functional'



You would be forgiven if you thought the "F" in F# -- which made its debut as part of Visual Studio 2010 -- stands for "functional." After all, F# (pronounced "F sharp") is a functional programming language for the .NET Framework that combines the succinct, expressive, and compositional style of functional programming with the runtime, libraries, interoperability, and object model of .NET.

But Don Syme, inventor of F# and leader of the team that incubated the language, has a different, truncated, and entirely whimsical definition.

"In the F# team," says Syme, a principal researcher at Microsoft Research Cambridge, "We say, 'F is for Fun.' F# enables users to write simple code to solve complex problems. Programming with F# really does make many programming tasks simpler, and our users have consistently reported that they've found using the language enjoyable."

Indeed, F#, which has been developed in a partnership between Microsoft Research and the Microsoft Developer Division, is already popular with the .NET developer community. The language is widely known in the academic community and among thought leaders, and the list of admirers will only increase as Visual F#, the result of a partnership between Microsoft Research Cambridge and Microsoft's Developer Division, becomes a first-class language in Visual Studio 2010.

"F# brings a really practical and productive functional-programming language into the suite of languages that Visual Studio and .NET developers have available to them," says Luke Hoban, senior program manager for Microsoft's Visual Studio Managed Languages team. "F# provides new tools for existing Visual Studio developers and extends the reach of Visual Studio to new audiences.

"Functional programming offers important new ways to think about problem solving. The F# Interactive lets developers work interactively with data and application-programming interfaces in a lightweight, explorative environment. F# also provides a set of core features for making parallel and asynchronous programming easier."

The language enables explorative programming, with the flexibility to translate requirements into code easily. That ability makes F# particularly valuable for the technical, algorithmic, parallel, and data-rich fields, with applications ranging from financial-market analysis to machine learning and from scientific usage to game development.

Such versatility delights Andrew Herbert, Microsoft distinguished engineer and managing director of Microsoft Research Cambridge. But he's not surprised.

"Over the years," Herbert says, "Don has been a significant contributor to Visual Studio, being one of the Cambridge team that did the early work putting key features like generic functions in the .NET runtime. I am immensely proud of this achievement."

Syme, of course, is in better position than anyone to provide a detailed definition of his language -- and the benefits it has to offer.

"F# is a simple, succinct, efficient functional programming language for .NET that lets users concentrate on the problems they are solving rather than getting lost in programming details," he says. "Its succinct syntax and powerful type inference lets users stay closer to the domain they are working in, and the integration into .NET and Visual Studio gives rich access to the expansive .NET platform.

"F# has strong support for parallelism and concurrency, through its support for immutability and asynchronous programming, and tools such as F# Interactive enable exploring data interactively, analyzing, visualizing, and testing against live data sources. This interactive development then scales directly up to full .NET component development, without having to rewrite code. F# has established itself as an innovative language on the .NET platform, and many developers have been attracted by looking for interesting new language options when working on .NET."

Visual Studio 2010 includes the 2.0 version of F# -- the first supported, product-quality release. This will enable usage by a broader set of developers, and the language benefits from Visual Studio debugging and compiling capabilities.

The Visual Studio release includes important new features of F#:

  • A simple, succinct functional syntax.
  • A rich .NET object-oriented programming model.
  • Integrated parallel and asynchronous programming features.
  • Units of measure.
  • F# Interactive.

"A programming language takes several years to mature," Syme says, "and this is what we've been doing from 2005 to 2009. This has resulted in a highly stable, efficient, and powerful language, available both as freely usable standalone tools, including visual editing tools, and also as part of Visual Studio 2010. We now have a powerful and stable base functional language and library for use in professional development contexts -- a wonderful result."

A functional programming language such as F# -- which can be used on varied platforms, such as Mac and Linux, in addition to Windows -- provides a tool bag of functions from which users can pick to solve their problems. Such languages operate on a higher level, and this abstraction of functionality from coding is a big benefit in certain domains. That's what led Syme and colleagues to the F# project.

"Functional languages attract me because of their simplicity even when solving complex tasks," Syme says. "A good functional program is like a beautiful poem: You see the pieces of a solution come together."

Work on this particular verse began seven years ago, when he identified a need for a functional programming language that integrated seamlessly with the .NET platform.

"My research vision is about making typed functional programming work in practice," Syme explains. "Strong typing is a wonderful thing: It makes your code more robust, it helps you understand and navigate complex objects, and it allows a visual environment to inform you when you make basic mistakes. And functional programming offers really powerful tools to simplify a huge range of programming tasks. But traditionally, it's been hard to deliver these to practicing programmers without losing something big, such as succinctness or objects.

"F# solves the questions of typed functional programming on the .NET platform. Along with features such as C# and .NET generics, which I've also worked on, it fulfills this vision. But further than that, it also opens new research questions, as we continue to seek to simplify complex problems using programming techniques."

The core syntax of F# follows in the tradition of ML programming languages, in particular, OCaml, and the language also incorporates key ideas from such languages as C#, Haskell, and Python. F# continues a long tradition of research and development by starting with the design of core ML and building atop it.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video