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.

Enjoy this post? Continue the conversation with me on twitter.

Tags: , , ,

4 comments

  1. I think this is a great approach! When I first started presenting on F#, I talked mostly about the greatness of immutability by default, asynchronous workflows, higher order functions, mathematical provability, and the F# interactive. However, the more I talked to people, the more I found that the initial draw seemed to be the terseness of the language, then to function composition, and only later to the previously mentioned awesomeness. I like the approach taken in the slide deck that Don Syme used for his F# tutorial at JAOO 2009 (http://blogs.msdn.com/b/dsyme/archive/2009/10/10/f-tutorial-code-and-slides-jaoo-2009-edition.aspx). The first several content slides are nothing but comparisons between “painful” C# and “pleasurable” F#. Ted Neward expresses this a bit as well (http://blogs.tedneward.com/CommentView,guid,8dd248aa-f023-4739-8f37-0a51ad70c20b.aspx) when he states that cases should be shown regarding how F# can make the developer’s life easier. I also think it’s important to show the C# and F# code side by side to help acclimate experienced C# developers to exactly what they are looking at. F# can be a pretty big culture shock when one first sees it; however, the simplicity and power of the language shines forth very quickly with a few simple explanations.

  2. […] This post was mentioned on Twitter by John D. Cook, Richard Minerich. Richard Minerich said: Blogged: Love the Lambda (at Code Camp Hartford 3) http://is.gd/cXZU6 #fsharp […]

  3. […] the Lambda This talk is a bit of an unfinished project.  The basic idea is that F# allows you to implement features that would requite compiler changes […]

Leave a comment