Matthew Podwysocki is a senior consultant for Microsoft platform technologies in the D.C. area. He's been programming since he was a child and has a
particular interest and passion for functional programming.
Functional programming is all the rage these days. General purpose imperative languages (like C# and C++) are adding functional constructs to help improve software developer prodcutivity in an increasingly concurrent general purpose computing environment
as notebooks and PCs with multiple processors are now the norm.
Matthew was in Redmond a few weeks ago, so we thought it would be awesome to invite Matthew into the the lair of our resident functional programming extremist (though I must say that Erik is mellowing out with age), high priest of the lamda calculus, category
theorist and Expert to Expert host,
Erik Meijer. Now, it's a little scary to be asked into Erik's den of functional orthodoxy (aka Erik's office) and be put to the task of explaining functional principals in a way that is widely accessible to developers who have little or no experience with
thinking functional, but Matthew was up for the task and spends most of the time at Erik's whiteboard explaining important functional programming concepts (Haskell and F# are the languages used in the examples, but the language isn't that
important - the
concepts are), sharing some his very interesting history with us, waxing on future directions in programming, engaging us in a really interesting conversation. Great job, Matthew!
Enjoy!
Duration: 1:07:41
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
For example, assuming we have a promise library with these operations:
Pseudo code:
You could implement a download function like this:
Use it like this:
You can extract a pattern. If you have a value of type a, but the value is asynchronous (like a web page); it's really a function that you give a callback to:
So it's a like a request in the above example: you don't have the actual web page, but you have a function that you can call (BeginGetResponse) and this function calls your callback when the web page arrives.
We can extract the pattern of taking an async value and producing a promise out of it.
And implement download like this:
Or if you don't support partial application:
Why did the F# team go for asynchronous workflows instead of this approach?
Back to a more line of business view of things, Eric talks a lot about Haskell from the "everything functional" point of view, but where do you draw the line in the sand on what to use in the real ".Net" world; F# or Haskell? Especially as Haskell has the .Net libraries.
I like what Matthew said about all a programmer really wants to do is a put/get and have the syntactic sugar handle the boiler plate coding for the processing of the exception. Even with Haskell (while I've not touched it since for some time) I haven't see how easy it is to process exceptions. It appears that it's designed for a perfect world that doesn't have exceptions. Is that really the case?
I loved this interview! Great stuff guys... keep on teaching.
awsome stuff! what i really like about erik is the uncondecending tone of all his interviews, its only about relaying understanding
Real World Haskell
Your thoughts around pure actions and purity is interesting, but since C# is a first class object oriented language with many imperative features, it's hard to bolt on such concepts as immutability (deep and/or shallow), purity, side effect free functions and so forth. With the utilization of Code Contracts for .NET 4.0, we could get part of the way there, but for the most part, any checks for purity are mostly just suggestions and not enforced. Instead, concepts such as these belong in its own language, for which F# is well suited on the .NET platform. Although there are projects to bring Haskell to interoperate with .NET hs-dotnet.
As for unifying TPL and Async Workflows remain to be seen and it may happen. I can't speak for the F# team on this one although we do like to talk often enough.
Given that reference variables can already be null or else point to something useful, don't they already have what is needed to represent the maybe monad? All that's lacking is the convenience of bind. An extension method can act as the bind operation and that's all you need, isn't it? Or have I missed something (I'm relatively new to Haskell!)
In Spec# they used MyRefType! (exclamation suffix) to mean non-nullable; so the default is wrong but they were aiming at backward compatibility with C#, so they had to go that way. And then they would just look for an if (myVar != null) and silently make myVar non-nullable within the truth block.
It looks like the closest we'll get to this in real C# is the Code Contracts library in CLR 4.0, but I really wish non-nullable was the default. Unfortunately it complicates the syntax in some areas (where should non-nullable instance fields in a class be initialized?) but it would surely have been worth it, as Hoare says.
C
Hello guys
this video on Perspectives on Functional Programming aside from being as totaly interesting as with all the other related videos had the nice thing of showing some recommended books to get more information on where to do more research on your own was fabulous.
I think it would be nice to add some way of letting c9 users to contribute on each videos pointing to other sources where to find information, like some webcasts, videos, articles, books (in the same post screen) so people can have a quicker access to other recommended material and shorten the time spent in searching for the correct information on the internet.
Great work your doing, i find it fantastic
best regards
hec
The best part of the video, in my opinion, was how you revealed that C++ is like a giant state machine. I never thought of this, and this idea you presented made monads finally "click." As C++ is basically one giant state, in which it is assumed that each operation produces side effects, finally got it to fit in. My problem was that since I came from a mostly imperative background, I really didn't understand what pure really meant. If you were to ignore the current technological limitations such as division by zero, explaining what the tail of an empty list would be, etc, then there would never be a single issue arising from any operation in a pure haskell function!
Thanks again for the info, and especially for the maybe monad and C++ ideas. You guys explained it perfectly =D
I am into moving into functional programming (Haskell, F#) for the last few months. I have read Expert F#, Real World Haskell etc.
I am liking the ideas and styles and started coding some fun stuff with great things there in F#.
I was disappointed by the quality (succinctness and clarity) of this video compared to other numerous videos which I have seen from c9 or msdn. (Maybee worst of all which I have seen) Sorry, Matthew and Eric, but I missed the flow and stopped watching the video in the middle.
I am sorry if I am rude but I got one point from this lecture that intellisence is some kind of bad thing. The examples could have been given either in pseudo code (without any reference to syntax) or with correct syntax of either F# or Haskell.
does anyone know where i can find "Introduction to functional programming" book? amazon.com don't have.
Is this the correct ISBN #? 0134841891
cheers,
amir
Remove this comment
Remove this thread
close