The F# programming language will become a major .NET language with its formal April debut in Visual Studio 2010, as it transitions from a Microsoft research project. F# has become a surprise hit among .NET developers, and it is being treated as a “first-class language” by Microsoft, serving as a test bed for ideas, said Larry O’Brien, an independent software architect and technology analyst who also writes the “Windows & .NET Watch” column for SD Times.

Pronounced as “F-sharp,” F# is a hybrid functional and object-oriented programming language that was created by researchers at Microsoft’s Cambridge, U.K. lab to demonstrate interoperability between different programming paradigms.

Some of its features include dynamic linking, preemptive multithreading and SMP machine support, and Unicode strings. It also is highly immutable—meaning that objects’ state cannot be modified once created—and has an implicit type system.

Because F# has an implicit type system, source code is smaller and the syntax is simpler, said Rick Minerich, a Microsoft MVP (Most Valuable Professional) and F# user group leader; he is also a software engineer at component maker Atalasoft.

“It is a stronger typed language than C#,” he explained. “C# makes no guarantees about things you are passing around. In F#, you deal with unexpected results sooner and more clearly.”

Microsoft has been using F# to build libraries for its software, including Microsoft Server Foundation, a set of algorithms that were tested in F# and then moved to C#, said Edgar Sánchez, a Microsoft regional director, an individual recognized by Microsoft’s Developer Platform evangelism group for technical expertise.

Libraries written in F# can extend languages like C# with its own capabilities, and a developer wouldn’t necessarily need to learn a new language or even know that they are using F#,  explained Amanda Laucher, a developer with ThoughtWorks, a consulting and development company. “It doesn’t add complexity to the system, it just adds another DLL.”

However, O’Brien was sour on the prospect that mainstream developers would write libraries in one language and then use them in another. “It seems to me that people are either writing entire applications in F#, or [they] are very advanced ISVs who might do a component in F# that they sell or license for general use,” he said.

Andrew Binstock, principal analyst at Pacific Data Works and writer of SD Times’ “Integration Watch” column, believes that it is likely that Microsoft will migrate popular features from F# to C#, and eventually to Visual Basic.

“If Microsoft were to give F# its full backing (as with Visual Basic and C#), then it might break out. But I can’t see a reason Microsoft would do this unless functional languages suddenly become widely adopted,” Binstock explained.

Adoption has indeed been slow. In Forrester Research’s most recent software survey, zero out of 800 clients indicated that they were using F#, and there were only single hits for functional languages such as Erlang and Haskell, said principal analyst Jeffrey Hammond. “Maybe I’m just not talking to the right people, but I’m not running into it at all with the clients I talk to.”

The F# language, according to Luke Hoban, senior program manager for F# at Microsoft, does have a number of benefits. It is “ideally suited” for parallel, algorithmic, technical and explorative development domains, he said.

For example, because Microsoft’s .NET Framework Task Parallel Library was written in F#, the library benefited the language’s focus on immutability, Hoban said.

In F#, you literally just write an algorithm to parallelize tasks, said ThoughtWorks’ Laucher. “The C# threading model is ridiculous. F# does it very succinctly, and you don’t need to know anything to do asynchronous programming now.”

Further, F# offers the productivity benefits of .NET to developers, Hoban said.

“You type code out and see if it works or not,” Minerich explained. “You are not building classes; you are building functions. You can construct ideas without a lot of [application] infrastructure, and quickly see if it works out or not.”

A Visual Studio 2010 editor called F# Interactive can be used to experiment with F# code to see if it works, Minerich said. “It’s great for people from financial and [scientific] backgrounds to build complicated systems to ensure they are correct.”

Developers can also use F# to create individual components to extend their existing .NET applications, Hoban said. Specifically, F# modules can query and transform data, and make it easier to create data visualizations in DirectX, Windows Forms and Windows Presentation Foundation applications.

Other .NET languages, such as C#, are “difficult and verbose” to do data visualization productively, Laucher claimed.

F# can also perform the same tasks as Language-Integrated Query, a functional language that is integrated into C#, except that “you can write the entire program in it,” Minerich explained.

Those characteristics, which were migrated from functional languages, make F# ideally suited for data mining and for creating parsers and interpreters for domain-specific languages, said Sánchez.

F# provides strong processing capabilities for handling data structures in parallel, Sánchez added. Other .NET languages can then use those libraries for those parallel threads.

The F# team at Microsoft is smaller than the C# team, but it will build over time, Minerich suggested. “People in the Java world are excited about Scala, and functional languages make the manycore problem evaporate.”

C# could become more functional, but the language’s mutable state works against the developer in parallel programming, Minerich added. “It’s like trying to make a donkey into an elephant.”