June, 2010


21
Jun 10

Love the Lambda

Just this past Saturday I gave a completely new talk at the third Code Camp Hartford.  This talk was inspired by a previous mid-talk realization: most C# programmers (and almost the entirety of my audience) have never written a single lambda expression or anonymous delegate.  From this I further realized that I’d never be able to teach F# to those who are completely unfamiliar with the concept of functions as first class language constructs.  First, this idea and its ramifications would have to be taught.

lovethelambda

So the idea for Love the Lambda was born:  I would demonstrate both the usefulness and sheer novelty of first class functions and do so simultaneously in C# and F#.  More than that, I would use the opportunity as a kind of F# omnibus.

Here was the general game plan (as written by me imagining the thoughts of some intelligent, but yet uninformed, person sitting in the audience):

  1. First class functions sure are great!
    1. Oh man, and with closures they are even better!
    2. I’m going to use this stuff in C# all of the time!
    3. Wow, that F# code looks so much cleaner than the C#!
  2. Now check out what you can do with partial application!
    1. Oh wow, this pipelining stuff puts LINQ to shame…
    2. …and function composition is amazing!
    3. Hey, wait a minute, you can’t do this in C#…. :(
  3. Good thing F# integrates really nicely with C#.  I can pull it right into our existing projects!
    1. Plus F# has tons of other amazing stuff, I’m going to start playing with it tomorrow!
    2. I can’t believe how much less code I need to write when I use these features!
    3. F#, where have you been all my life?!

All that said, the first iteration of this talk worked out a bit different than my initial vision.  This was mostly due to running out of time when constructing the presentation.  I still think the ideas I was trying to convey are in there but not as sharp and as easy to grasp as I’d like.

Still,  the attendees seemed really happy with the talk and the review forms agreed.  Everyone left my talk loving the lambda at least a little bit more.

If you are interested, I’d encourage you to download my slides and code samples.  Also, I’m always interested in hearing about how I might improve my talks, or further spread my love of functional programming.  Please don’t hesitate to contact me if you want to share ideas.