Jun 26

A Taste of F# Interactive in Visual Studio

Here’s a taste of some great new functionality that will be in the next release of F#, which we should have out sometime in the next week or so. The cool thing here is not just the pretty graphics (which you’ve been able to do in F# for a while now), but F# Interactive (fsi.exe) embedded as a tool window in Visual Studio. Click on the screen shot for an enlargement.

Also shown is something I haven’t made much noise about on this blog, and that’s the ability to display windows interactively from F# Interactive. The windows are fully active - they can paint and respond to interactions while the programmer evaluates new expressions, code, types and classes in the interactive session. You can also dynamically load new .NET components on-the-fly.

At the bottom of the screen you’ll see a tool window containing the F# Interactive session. The WinForms/DirectX window in the foreground was created by running simple F# code such as

let form = new Form();;
form.Text F# surface plot”;;

as well as some introductory DirectX triangle creation.

The code shown in the editor is part of this script - we’ve just executed the command that specifies a new function to display (this is the line highlighted in the editor). We did this just by evaluating the code in the F# Interactive Session below using a key short-cut. (I’ve scrolled the F# Interactive window back up to the top so you can see the banner printed out when F# Interactive starts up.)

What’s really striking is the combination of interactive visualization, Visual Studio, .NET programming and efficiently executing F# code (remember, .the floating point code is running as optimized native code, often close to C++ speed). We have a few things to add before this is complete: for example some form of intellisense in the interaction window. But this combination feels like it is bringing many things together nicely. (Aside: you can of course do interactive visualization when using F# Interactive from Emacs too :-) I’m not so sure about “vi” !!)

Leave a Reply