Feb 22, 2011

Getting Started with F#

I've heard about F# for a couple of years and even attended a rather disjointed rambling talk about a couple of years ago at a Code Camp. I didn't really get excited about it until recently when I watched a video from Lucas Bolognese. I'm often working on signal processing and data collection systems and anything that makes manipulating data easier gets my attention. Having it do so asynchronously and in parallel by adding a couple of keywords gets my downright giddy. While his example on downloading data from the web into a CSV format wasn't exactly analogous to what I do, the concepts seem pretty similar.

While watching Don Syme's first tutorial I tried to follow along and things didn't quite work. I had downloaded the most recent F# CTP as of February 2011 and I was using it inside VS 2008 (not VS2010). On thing not mentioned in Don's tutorial is that creating a new F# application brings in very few of the .NET namespaces including those needed by his second example.

open System.Windows.Form

is not going to work until you add a reference to System.Windows.Form and while you're at it, save a trip and add System.Drawing as well.

The rest of the example is:

let form = new Form (Visible=true)

form.Click.Add(fun _ -> printfn "click")

Now when I see this, I' wonder where is "click" going to show up. So I highlighted the code, right-clicked and selected the Send to Interactive option.  It turns out it shows up in the F# interactive window.

In the next example, he explores parallelism. Again there are some prerequisites you need that aren't mentioned. In this case it's the Microsoft parallel extensions. While I could find some links to old versions for VS2008 it seemed that the new versions were meant for .NET 4 and VS2010. So at this point in my exploration of F# I decided to pause while I wait for VS2010 to arrive.

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.