NEW YORK-Microsoft plans to deliver a new general-purpose programming language to developers, known as F# (pronounced F Sharp), that takes advantage of the functional programming model.
Speaking at the VSLive New York conference here on Sept. 8, Luke Hoban, the F# program manager at Microsoft, said F# is a functional programming language for .NET, which will join C# and Visual Basic as core .NET languages.
Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast with the imperative programming style that emphasizes changes in state.
“Functional programming means functions are very important,” Hoban said. “With F# we pass around functions like any kind of data.”
Hoban further explained that “F# is a functional, object-oriented, imperative and explorative programming language for .NET.” And, “F# makes an inference that a language should be good at doing explorative development,” he said.
However, “by no means is F# a replacement for C# or Visual Basic, which are great for mainstream development,” Hoban said. “F# is meant to go out and extend the reach of .NET to new developers and new types of developers.”
F# started as a research project in Microsoft’s research lab in Cambridge, England. “And about eight months ago Microsoft decided there was an audience we could target more aggressively” with the language, Hoban said.
Although Hoban described F# as a general-purpose language, he said it is particularly suited to doing technical algorithms and explorative tests, financial modeling and analysis, data mining, scientific data analysis, domain specific modeling, and academic uses. In fact, Hoban said many of the early adopters of F# are financial services companies in New York on Wall Street.
Hogan also noted that F# borrows from other languages and is strongly typed, has a succinct syntax, is scalable, has libraries, and is explorative, interoperable and efficient. Other characteristics early users have listed as benefits of F# are that it is quick coding, supports scripting, has good performance, is symbolic and has .NET integration.
At the end of August, Microsoft released the September CTP (Community Technology Preview) of F#. That CTP features improved integration with Visual Studio 2008 and was co-developed by Microsoft Research in Cambridge and Hoban’s group in Redmond, Wash. The September CTP of F# also features improvements to the F# language and libraries to make them simpler and more regular. And there is also a new language feature, Units of Measure, which extends F#’s inference and strong typing to floating-point data.
Don Syme, the Microsoft researcher who devised F#, in a blog post, said:
““F# is a simple, type-safe, efficient, scalable language for the .NET platform that supports both functional and object-oriented programming. One of the key things about F# is that it spans the spectrum from interactive, explorative scripting to component and large-scale software development. In this release we’ve made major improvements to the language, libraries and tools across this spectrum.”“
Along with the CTP, Microsoft also launched “a new F# Developer Center on MSDN [Microsoft Developer Network],” said S. “Soma” Somasegar, senior vice president of Microsoft’s Developer Division, in a blog post. “This developer center provides resources for F# developers and links to F# user communities.”
Hoban said Microsoft will deliver in 2009 the first supported release of F# that will be aligned with the next version of Visual Studio. However, Hoban said it is not yet clear whether F# will be delivered as an add-in or “out of the box.”
Because F# supports immutability, it is good for parallel programming, Hoban said. “We treat things as being immutable, and immutability comes up when we get to more parallel applications. … What immutability means for F# is if you define a value you can’t change it-it’s not mutable.”
F# has “the static typing of C# with the succinctness of a scripting language,” Hoban said. The language also features a type inference capability, where the compiler can tell what type the developer intended to use. Indeed, Hoban demonstrated the integration of F# with Visual Studio, where he hovered the cursor over a piece of code and a pop-up displayed what type the code was. “On the language side, some of the consistent feedback we get about F# is that the combination of type-inferred programming and interactive exploration allows you to develop correct algorithms and objects quickly and with a very low error rate,” Syme said.
F# also supports pattern matching, functional collections and scripting via the Script.fsx extension, said Hoban said, who showed a demonstration in which he used DirectX and F# to do visualization of data.
Regarding performance, “in F# you get really good performance,” Hoban said. “F# can probably run 10 to 20 times faster than Python. … You should look for performance at about the same level as C#.”
Moreover, Hoban said as proof of the applicability of F#, “we develop F# in F#,” with only one or two side projects in C#, Visual Basic and C++ contributing to the development of the language.