LDNUG: Mixing functional and object oriented approaches to programming in C#
On Wednesday evening my colleague Mike Wagg and I presented a variation of a talk I originally presented at Developer Developer Developer 8 titled ‘Mixing functional and object oriented approaches to programming in C#’ to the London .NET User Group at Skillsmatter.
The slides from the talk are below and there is a video of the talk on the Skillsmatter website.
These were some of the lessons I learned from this version of the talk:
- I recently spent a bit of time flicking through Scott Berkun's 'Confessions of a Public Speaker' and one of the suggestions he has is that people aren't interested in how you got to your current opinion - they're more interested in hearing what you've got to say. While I think a story based approach is more fun to watch, in the original version of this talk I felt I spent too much time detailing where ideas had come from even though that information didn't add much value to the talk. We cut that out this time and I think it worked better as a result.
- I haven't done a paired talk before but I found it a much more enjoyable experience than when I just presented on my own. Mike took the role of the object oriented guy interested in how functional can work in that context while I took the role of the guy who's really interested in functional programming and wants to put it into C# code whenever possible. It was quite fun playing those roles especially when I was showing some of the slides on passing functions around and continuation passing style as the code became more and more difficult to understand.
- Zi suggested that it would work better next time if we paused at the end of slides with code on so the audience would have time to let it soak in and ensure they understood what was going on so this is something to try for next time.
- Mike and I were unsure whether the introduction where he covered how C# had evolved through the different versions would be useful but this was a part of the talk which got a lot of positive feedback and several people mentioned that they had done something similar at their work place when explaining LINQ to colleagues.
- Liz Martin pointed out that the talk was effectively about knowing your language and how to use it an effective way without causing yourself too much pain. I think this is probably a fair summary and if taken further perhaps explains how we end up with different idiomatic patterns of use in each language.
- Next time I'd look to explain some of the more complicated functional code a bit better and perhaps build up to it with some simpler examples. This time it was more to demonstrate how impossible the code can become if you take a functional approach to the extreme in C#. It also seems like there is some overlap with some of the patterns of Domain Driven Design and how the fit in with these two approaches to programming.
We had a discussion afterwards about some resources for learning functional programming. These were some of the things mentioned and resources I find useful:
- Real World Functional Programming - I started learning about F# from this book and it provides a nice introduction to functional programming concepts with examples side by side in C# and F#.
- Functional Programming Fundamentals - Erik Meijer's series of lectures on functional programming based mainly around Haskell recorded for Microsoft's Channel 9. I've only watched a couple of these so far but they seem to provide a decent introduction.
- Planet F# - a syndicator with posts by various people about what they're doing with F#.
- Structure and Interpretation of Computer Programs - a computer science introductory text used in introductory courses at MIT. It's not only about functional programming but there are relevant sections.