Posts for #F#

Yesterday I presented my talk Being Functional to the London .NET User Group. First of all: thanks to Dylan and Ian and whoever else was involved for organizing this event and inviting me, and to Skills Matter for making their fantastic CodeNode venue available to the group! I had a great time and I believe everybody else did, too 😃

Feel free to get back to me if you have any questions or comments! Here's the download of samples and slides I used during the talk.

I almost (well, actually - for a while) forgot to blog about this, but was prompted by the Pluralsight newsletter that came out yesterday. So here goes: my Pluralsight class Introduction to F# is available now! Please follow the link below to check it out, and of course feel free to get back to me with any feedback you have! Introduction to F# @ Pluralsight

On April 13th, during Microsoft’s inaugural UK TechDays event, I’ll be speaking for the Edge UG at the main Fulham Broadway venue. This is part of what Microsoft call the Fringe events, community hosted events that complement the main Developer and IT Pro days. I will be speaking about functional programming on the .NET platform, using both the C# and the F# languages. Here’s the abstract for this talk:

It seems to turn into a shoot-out: listing directories is suddenly en-vogue! 😃 So, Craig Andera posted this code in written in Clojure, which lists some directories lazily, and Chris Sells thought he could do that in C#, too. I thought these code examples all look rather verbose – in the case of Clojure because in that way rather typical for Java, the APIs are pretty verbose to use, and in the case of C# because of all the syntactic, well, ahem, necessities, as well as the fact that there’s no language feature for integrating nested sequences seamlessly. Keeping it nice and simple, in F# that example can look like this:

open System.IO

let rec GetDirectoryDescendants(path) =
    seq {
        yield! Directory.GetFiles(path)
        for subdir in Directory.GetDirectories(path) do
            yield! GetDirectoryDescendants(subdir)

When I was at DevDays in The Hague last month, all my talks were recorded. Until now I wasn’t aware that something was actually going to happen with these recordings 😃 Now the first one of them has been published on Channel 9, here:

I’m wondering if my FP in C# talk will also be published - while I was there, that one seemed to be the most popular one I did. I’ll ask!

I’ll be traveling down to London tomorrow for DevWeek 2009, where I’m going to do a workshop on F# on Monday and a few sessions on C# and F# on Thursday. Are you going to DevWeek? Are you going to be in London over the next few days? If you want to meet up, just let me know and I’m sure we can work something out! I’ll be twittering while I’m there, so following me on Twitter will be a good way of finding out where I am, if you fancy joining me for a pint!

Editor’s note: In case you’re reading this in 2019, like I recently did, it should be pointed out that this opinion piece was written in the early days of F#. The language has since evolved in a variety of ways, which is not to say that the problems described below are necessarily solved today – but the position of F# in the landscape of .NET languages is now clearer than it was and I don’t agree anymore with the proposals I made in 2008.

In my continuing efforts to make XPO work fully with F#, I found the next problem to deal with: the extremely linear way of thinking of the F# compiler.

The next problem I found in my efforts to make XPO work with F# is documented here: Null values for F# classes – basically, I can’t just set a variable that has a reference to another object to null in F#.

The general assumption in F# is that null values are a threat and so the languages discourages their use. I totally see the point and if all I wanted to do was create classes (or perhaps not even those) for use in F# itself, I wouldn’t have a problem with it – but interop is an important thing for F#, as I see it, and all the rest of the .NET world makes elaborate use of null values. Null values are the (rather more dangerous) alternative to F# Options to most .NET developers – exactly the same purpose, just a less elegant implementation.

I have been working on getting a sample for using XPO from F#. My first sample was easily created back in January this year:

open DevExpress.Xpo
type Person = class
  inherit XPObject as base
  public new(session : Session) = { inherit XPObject(session);
    name = string.Empty

  val mutable private name : string

  member public x.Name
    with get() =
    and set(v) = <- v

let person = new Person(XpoDefault.Session)
person.Name <- "Wally"

I was playing around a bit today with F#, trying to write some real code that interfaces with WPF. Here are a few things I found – very much a “note to self” thing, but if you happen to be interested, please comment or ask.

Number 1 - implementing interfaces that include events is a PITA