Microsoft brings F# to Visual Studio
Modern functional programming langauge uniquely well-suited for multicore environments, adherents claim.
- By Joab Jackson
- Jan 26, 2009
The next version of the Visual Studio, Microsoft's integrated developer environment, will feature a new Microsoft-developed programming language called F# (F sharp). What makes F# different from other Visual Studio-supported languages is that it is what developers call a functional programming language.
Such an inclusion in Visual Studio 2010 signals a victory for this once-obscure branch of programming.
Although functional languages have been around for decades, they largely have been discarded in favor of traditional imperative languages, such as Java and C. Advocates claim, however, that functional languages run faster and take less time to develop once you know how to program in them.
Each year, the International Conference on Functional Programming (ICFP) holds a programming contest, in which the winners are picked by the how quickly their programs complete a given task. In most cases, functional programs such as Objective Caml and Haskell take the prize (last year's Java championship being an exception).
The increasing prevalence of multicore processors also bodes well for functional programming paradigm's future. To get the most from multicore chips, programmers must cut their programs into smaller tasks so they can execute in parallel across multiple processor cores—an easy task in a functional environment.
Microsoft Research first developed F#. The idea was to develop a modern functional language that could work in a .NET environment, and would also share characteristics with the more commonly used imperative languages, notably Microsoft's C#.
At first glance, F# may seem like a foreign beast to most programmers. Traditional imperative languages create programs by establishing a set of values in memory, called a state, and then changing the state when necessary.
A functional language minimizes this state by forcing the programmer to write an application as a "composition of functions," explained Vlad Vinogradsky, a senior architect evangelist from Microsoft's public sector group. Functions "calculate a return value, and that is all that they do," he said. This approach assures that if a value is changed, it won't inadvertently change another part of the program (called a side-effect).
While F# is a complete functional language, it is not a pure functional language, Vinogradsky cautioned. It also borrows many characteristics from the standard imperative languages.
"You could describe F# as a multi-paradigm language. It supports object-oriented imperative programming, which a lot of people are used to. It does so in a syntax that would not be foreign to a C# or Java programmer. And at the same time, it also has all the features and facilities that one would expect from a functional language," Vinogradsky said.
The idea is to "introduce functional languages to people who have been working in object-oriented or other imperative languages," he added.
Although Microsoft has had a beta version of F# available for Visual Studio 2008 for some time, the first fully supported production ready version of the language will be included in Visual Studio 2010, expected to be released within the next year or so.
Like the other languages in Visual Studio, F# will be part of the .NET Common Language Runtime (CLR), a runtime framework shared among languages for executing programs on a Microsoft Windows computer. This will allow programmers to mix bits of code written in F# with those written in other .NET languages.
The language is being added as part of an overall effort to expand the range and types of languages that can be used within Visual Studio and the .NET framework, Vinogradsky said. F# in Visual Studio will have most of the features that C# and Visual Basic have long enjoyed, such as debugging and auto-completion.
Given that the learning curve for this language is not inconsiderable, what sorts of projects would make using F# worthwhile? This language would work very well for complex algorithmic processes, such as data mining, according to Vinogradsky.
Programs that must undertake a lot of complex mathematical calculations would also work well in F#, since the language so closely mimics standard mathematical procedures. Like Sun Microsystem's Fortress, F# could also replace the long-in-the-tooth Fortran, which is now widely used by scientists for heavy numerical calculations.
F# also works very well in parallel environments.
"The interest in functional languages is surging right now, I think, primarily due to interest in concurrent programming, what with multicore chips coming out," Vinogradsky said. Functional languages are uniquely suited for working in environments with many processors, or multicore processors.
Since the functional approach minimizes the global state of a running program, it allows the program to be easily separated in parallel operations. "Each function is independent, so it is very easy to change without any side-effects," he said.
Vinogradsky agreed that F# would not be applicable for many applications; it is another tool in the arsenal that Microsoft offers developers. The company "is trying to provide choice for developers, so they can pick the right tools for the job," he said.
Joab Jackson is the senior technology editor for Government Computer News.