Microsoft stealth launches 'historic' programming language
Hidden F# strikes right note
Launching a new language is easy - getting it used is hard. The combination of existing code and existing skills is a strong barrier to adoption, and even excellent languages like Ruby and Python have struggled to break out of their niches.
What hope is there for F#, the new language that Microsoft has sneaked into Visual Studio 2010, launched this month?
"I think it's an amazing moment," says its principal designer, Microsoft researcher Don Syme, an Australian now based in Cambridge. "It represents part of the history of programming language design and development here in the UK."
Perhaps it does. But you would not know it from most of Microsoft's marketing effort for the new Visual Studio. F# tends to get lost in the fuss about other new features. I downloaded Microsoft's Why upgrade to Visual Studio 2010? white paper and not only is F# missing from the "Top ten reasons to buy" - it's not actually mentioned at all.
That is a shame. F# is a functional programming language, and there are good reasons why functional programming deserves wider use, such as its suitability for the concurrent programming required for optimal performance on today's multi-core systems.
F# is also succinct. During a talk at the recent QCon London programming conference, Syme showed a series of slides, headed Pleasure and Pain, showing how F# code can be shorter and more expressive than its C# equivalent, sometimes to the extreme.
Following his QCon talk, I spoke to Syme about the new language. How did F# begin?
"I've been doing functional programming since 1992. I had been using the ML family of languages, including standard ML and OCaml, and wanted to see that paradigm being strong on the .NET platform. We started F# as a research project. We could experiment with the functional paradigm in practice, and understand where it was most beneficial and how it would fit in."
So how does F# differ from, say, OCaml?
According to Syme: "The core language of F# is heavily inspired by OCaml. If you look back at the ML languages, the core of these languages has been surprisingly stable, from the early seventies. It's a question of what you do around that. One of the major questions is about object-oriented programming. Another question is what you would historically have called module system design. F# differs on those design decisions from other ML languages because the aim is to build a language which integrates into the .NET component development model. That means we do embrace .NET object-oriented programming.
F# can be remarkably concise compared to C#
"Another major design difference is with regard to parallel programming, where we embrace the idea of lightweight threads and what we call lightweight agents in the language and in the core language. We use techniques that come from Haskell for that purpose."
Speaking to Syme, Microsoft's main motive for including F# in Visual Studio becomes clear. Functional programming is popular in the financial community, where it is used for quantitative analysis. Finance is an important market.
"We find F# is very attractive to financial analysts and quantitative experts," says Syme, the reason being that it excels in data, parallel and algorithmic programming. "F# is attractive in places where the object oriented paradigm isn't a good fit for the kind of work that's being done," he says.
If F# is mainly intended for a specific programming niche, that would explain why Microsoft is not putting much energy behind promoting it. That said, it deserves more attention because of its suitability for the concurrent programming that has become necessary in order to take advantage of today's multi-core systems.
The Hejlsberg factor
Perhaps surprisingly, C# designer Anders Hejlsberg is an F# enthusiast, though he also plans to introduce functional features into C#. In a recent talk on programming futures, Hejlsberg said a functional programming language is easier to parallelize.
"I'm not running around modifying the state, and it doesn't matter how many threads there are because the state is safe to observe, and if two functions are independent they can be executed sequentially or in parallel and it doesn't matter ... [F#] is the first time we've seen integration of a functional programming language with an industrial-strength framework and toolset," he said.
Syme also is convinced that F# has a future that goes beyond financial analysis. He sees it as ideal for web programming, thanks to its use of lightweight "agents" that sit waiting to react to an event such as a network communication.
"We have a huge opportunity with F# to see the functional programming paradigm break out of the data-oriented kind of work, through to the modern world of web programming," he says.
The question: how to get that message through to Microsoft's marketing department? ®