Posted on 5/31/2008 4:26:00 PM by Justin Etheredge
I have been a bit quiet for the past two months on my blog, since I was doing a presentation at the code camp at the end up April. Well, I am doing a presentation at the upcoming June 5th Richmond .Net users group. For some reason when I get into working on my presentations (probably because I haven't done too many of them) I somewhat obsess over them. I write code and rewrite code, and google...google...google. I start becoming obsessed with exploring every little nook of something I am doing, and then in the end I still feel like I know nothing about my topic!
Well, my presentation coming up is on the features of C# 3.0 that have been borrowed from functional programming. It isn't a presentation about functional programming in C#, since C# is not a functional language. If you want to write functional code, write it in F#, you'll bang your head against the wall a lot less! I am mainly going to be talking about delegates, lambdas, closures, and higher order functions.
I am aiming this presentation at a intermediate level presentation, that is going to try to get at some more beginner content at the start. I don't want people who are not familiar with delegates and closures to be left out in the cold! Although I will assume that people at least know what delegates are, but I won't expect them to know what anonymous methods are or the fact that they are closures. I really want this presentation to be accessible, and I am worried that it is not going to be.
Closures, for some people (including me), can be some mind bending stuff. One of the things that I am going to do with closures is show how to do memoization. I feel like it is a very useful process, that can be explained in a somewhat simple manner. I am worried though that some people just won't be able to wrap their mind around it. So, I sincerely hope that I will be able to break it down enough for people to grok it. If I don't, I have failed.
On that note, I dropped currying and partial function application from my presentation. I just felt like their implementation in C# is extremely ugly, it is extremely complicated, and quite frankly its usefulness in a non-functional language is limited. It wasn't an easy decision, because mind bending stuff like that is just so exciting for me. Who knows why, I just love to look at a piece of code and say, what the heck does that do? Check it out...
public static Func<TArg1, Func<TArg2, TResult>>
Curry<TArg1, TArg2, TResult>
(Func<TArg1, TArg2, TResult> func)
{
return argument1 => argument2 => func(argument1, argument2);
}
I mean, just look at that. The first time I saw code like that I knew that an adventure was ready to being. It was like a kid staring through the front window of a candy store. And granted, once you understand it, some of the magic goes away but the adventure never ends. I am going to leave my currying code in my presentation project, just in case by some miracle we have some time at the end I can go into it. I doubt that will be the case though.
So, I am hoping that once my obsessing ends I am going to get back to doing some more blogging. I have a few great ideas for blog posts that came out of the Meet and Code dinner that we did the other night. So I can't wait to get them written up. I also have a few other ideas that I need to find time to get to. So, anyways, I hope that you can hold out for a few more days, and if you live in Richmond come see me talk on June 5th!