Keep an Eye on F#
The marriage of F# and Visual Studio has brought about unprecedented ease of use for a functional language, as well as excellent project- and team-organization facilities.
If you have a formal computer science education, chances are you have the desire and opportunity to experiment with several programming languages. Throughout my own education, I pursued C, Pascal, Lisp, Ada, Smalltalk and others, looking for the language that best fit my temperament and needs. The fascinating thing about different programming languages is that they exhibit different strengths and weaknesses, depending on the needs of the application.
My time as a professional programmer turned me to more mainstream commercial languages, but when I went into academia afterward, it gave me pause to once again consider the best set of languages for my work. Now, after settling down to largely a writing career, I have the ability to step back and look at the landscape, rather than pull up weeds.
A few days ago Microsoft released the community technology preview (CTP) of its F# language. You can find the developer center and download information from here. I downloaded it as soon as I saw it mentioned on Somasegar's blog. F# takes me back to when language choice said something about the problem you were trying to solve, rather than any corporate standard for production applications.
That's because F# is a functional language, in that it represents the more pure language of mathematics. Computation is simply the evaluation of mathematical functions of the basic type f(x). You can use it as a console interpreter, or integrate it within Visual Studio Professional Edition.
Because F# is a .NET language, it also has a ready-made class library and can be used for object-oriented programming. That combination gives it an excellent opportunity to pick up a heavy workload in .NET development.
F# doesn't require strict typing. It can infer types, although you can also specify a type. I always enjoyed type flexibility in Lisp, because it meant that I could use a variable in a way that made sense in a particular context, rather than go through the machinations of defining types, working around type differences and -- if necessary -- casting.
Of course, the trade-off is that the compiler has to figure out the type and allocate the appropriate storage, slowing down code execution. Of course, Microsoft .NET compilers are well used to dealing with the performance issues inherent in a managed language, so the drop-off in speed may in fact be minimal.
I wrote two small, more-or-less equivalent programs in C# and F#, and could discern no obvious differences in performance. But your own mileage may vary, depending on your programs.
The marriage of F# and Visual Studio has brought about unprecedented ease of use for a functional language, as well as excellent project- and team-organization facilities. Many developers interested in programming language features simply write a few small programs in the language and then put it aside. With the new Visual Studio integration in this CTP, developers can immediately use F# for more complex projects.
For the future, Microsoft is planning on making at least part of the component library for F# freely downloadable. Specifically, it's going to make available for download components it calls the F# PowerPack.
The PowerPack components include the FsLex and FsYacc tools, in addition to DLLs for compatibility, math, dynamic execution and query functionality.
F# isn't going to replace whichever .NET language you're currently using, though. It's a specialist tool, best used when your problem can be rigorously defined and concisely expressed using mathematics or the lambda calculus. Microsoft researcher and F# creator Don Syme noted in a blog post that users have provided feedback about the language's ability to enable fast development of correct algorithms.
"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 wrote.
And thanks to the flexibility of the .NET Framework, you may even choose to write a specific part of your application in F#, while writing other parts in C# or Visual Basic.
At the level of a CTP, F# isn't yet ready for prime time. Its integration with Visual Studio needs more work, and it's not at the point where Microsoft is willing to productize it. It may take some time to get there, but if you think it's too hard to do some things using C#, this new language may be part of your answer.
Peter Varhol is the executive editor,
reviews of Redmond magazine and has more than 20 years of experience as a software
developer, software product manager and technology writer. He has graduate degrees
in computer science and mathematics, and has taught both subjects at the university