By Rob Knies, Managing Editor, Microsoft Research
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 [APIs] 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.
“F# started in 2003 as a project to ensure that typed functional programming in the spirit of OCaml found a high-quality expression on the .NET Framework,” Syme recalls. “These languages excel in tasks such as data transformations and parallel programming, as well as general-purpose programming. Over time, F# has incorporated elements from other languages, too, and carved out an independent identity as a mixed object/functional language on .NET. The journey to create F# let us engage with top language designers from around the world—and with real programmers tackling hard problems.”
Those programmers represent a number of industry verticals, which are finding the language helpful for algorithmic analysis of large quantities of business information. Whether it be financial-market analysis, retail, scientific applications, or business-information management, F# makes it easy for analysts to experiment with different data and algorithms to obtain additional quality.
“F# gets used for all sorts of things,” Syme confirms. “We’ve seen a lot of interest and uptake from the financial community, where typed functional programming serves as a wonderful basis for data analytics and where questions of parallelism and efficient programming are very real. We’ve also seen fantastic applications in server-side data analysis, including in parts of the Bing ad delivery and analysis pipeline. F# seems a particularly good language for programmatic machine learning.
“F# scripting also makes F# ideal as a way to explore software components, develop algorithms, and investigate solutions to problems.”
But don’t get the idea that F# will be replacing C# as the predominant .NET language for professional developers. F# is complementary to .NET stalwarts C# and Visual Basic .NET, which remain integral to the majority of .NET projects. But C# and Visual Basic programmers can use F# components in their existing applications, enabling developers to maintain their current investments and integrate F# on a component-by-component basis.
Throughout the project that led to F# taking its place as a major .NET programming language, the goals have remained consistent: to combine the power and simplicity of functional programming with the tools, libraries, performance, and interoperability of .NET.
“This combination,” Syme enthuses, “is a match made in heaven, giving a synthesis of programming style and platform. We want to revolutionize how people think about programming and equip programmers in domains such as technical computing with tools to solve their problems.”
The F# team currently includes approximately 12 contributors. Syme credits Hoban as an integral player for “his grasp of what makes for successful language development—for everything from simplicity in an API design to pushing the boundaries with what can be done with the language.”
“In many ways,” Syme adds, “F# 2.0 represents the successful transfer of three independent major research results into product form. First, we have F# itself, developed by me with the assistance of James Margetson. Next, Andrew Kennedy has contributed the design and implementation of units of measure in F#, a direct transfer of the beautiful ideas from his research work. Finally, F# parallel and asynchronous programming has been influenced by many people, including Simon Peyton-Jones. I’ve been very grateful for his comments and support.”
Others who have supplied invaluable support include Martin Odersky, designer of the functional language Scala and a professor at École Polytechnique Fédérale de Lausanne, the Swiss Federal Institute of Technology in Lausanne, who hosted a visit by Syme during which key concepts behind F# came into focus; Ralf Herbrich, one of a number of colleagues who have applied F# within Microsoft Research; and Tomáš Petříček, a former Microsoft Research intern and co-author of Real World Functional Programming: With Examples in F# and C#, which Syme terms “one of the best books on applied functional programming.”
Syme also emphasizes the importance of Microsoft Research itself in the development of the language.
“Microsoft Research has given F# a long-term home,” he says, “which has allowed the language to mature in a context of intellectual curiosity and investigation. It’s also given us access to many of the best researchers in the world. The partnership we’ve developed with the Microsoft Developer Division is something we very much look forward to continuing.”
Along the way, the F# effort encountered and surpassed a series of hurdles.
“Combining object-oriented and functional programming poses several challenges,” Syme says, “from surface syntax to type inference to design techniques. I’m very proud of how we’ve addressed those problems. F# also has a feature called ‘computation expressions,’ and we’re particularly happy with the unity we’ve achieved there.”
Now, with F# having been added to the Visual Studio tool kit, it’s time for the team to turn to new challenges, right? Not so fast, Syme cautions.
“A recurring theme of F# is its focus on accessing information from outside the language,” he states. “Looking ahead, we want to continue to connect F# to rich data sources and external sources of functionality. There is a tendency in the industry to think that strong typing and navigability are necessarily lost around the fringes of an application. In many ways, C# and F# already dispel this myth. However, we have ideas about how to make external access even simpler and more intuitive, continuing to break new ground for typed languages.”
Meanwhile, on the product side, it will be interesting, Hoban says, to watch how F# is embraced now that it has received official release as part of Visual Studio 2010.
“We’ve seen a number of interesting uses across a broad range of software applications,” he says. “We’re also seeing many examples of F# being used to build components of larger .NET applications. This allows projects to seamlessly integrate F# in areas where it provides significant value without needing to change anything else in their applications.”
For Syme, staunch advocate of functional programming and making software development enjoyable, the prospect of people enjoying their work with F# is the ultimate reward.
“That,” he says, “makes me happy.”