Posted By: Charles | Oct 1st @ 8:50 AM | 78,893 Views | 84 Comments

Welcome to a new technical series on Channel 9 folded into a different kind of 9 format: C9 Lectures. These are what you think they are, lectures. They are not conversational in nature (like most of what you're used to on 9), but rather these pieces are entirely focused on education, coming to you in the form of a series of high quality technical lectures (1 or more per topic) on a single topic.

We kick off C9 Lectures with a journey into the world of Functional Programming with functional language purist and high priest of the lambda calculus, Dr. Erik Meijer (you can thank Erik for many of the functional constructs that have shown up in languages like C# and VB.NET. When you use LINQ, thank Erik in addition to Anders). 

Lecture Context:

Over the past two years, you've learned a fair amount about the functional programming paradigm's foray into general purpose imperative progamming languages (LINQ, Lambda's, etc in C# and VB.NET). And, of course, the newest language to join the Visual Studio family of languages, F#, is a functional language. You've heard us say how important functional language constructs are to the our current languages' capabilities to evolve in the right direction to meet the needs of the many-core future (the need for reliable and comprehensible concurrency, parallelism, etc) and, most importantly, to help vault computer programming into an age of compositionality (remember our talks on 9 regarding composability and evolution of software engineering as an engineering discipline?). Well, we decided to take a step back and teach you the fundamentals of functional programming at a level equivalent to any university. We even have a text book and professor who will expand our minds.

Dr. Erik Meijer will teach us Functional Programming Fundamentals using Haskell as the language for understanding the basic functional principles (in fact, the specific language isn't all that important, but Haskell is a pure functional language so it is entirely appropriate for learning the essential ingredients of functional programming. It is also a relatively small language and should be easy for you to get up to speed with Haskell once you understand the Why, What and How that underlies all functional languages...).

Now, we do have a textbook and you should go buy it: The great Graham Hutton's Programming in Haskell. We worked with the publisher, Cambridge University Press, to get all Niners a 20% discount on the book. Now, you don't need the book to learn a great deal from this lecture series since Graham's website has all the slides and samples from the book as well as answers to the exercises. That said, it's highly recommended reading and you should consider it.

The promotion code is 09HASK and it is vaild on both the Hardback and Paperback.

Hardback:

http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=9780521871723

Paperback:

http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=9780521692694

Note: This special offer is valid until December 31, 2009

 

In Chapter 1, Dr. Meijer takes us through the fundamental fundamentals of functional programming: The philosophy and history of functional programming. As you can imagine, these lectures will go deeper and deeper as the chapters progress, but you need to understand the philosophical and historical contexts. This will provide a nice layer of fresh conceptual soil in which to plant the seeds of understanding the technical details of functional programming, of functional reasoning.

Welcome to C9 Lectures. Enjoy and learn, learn, learn.

ALWAYS ask questions right here. Erik will answer them. Remember, he is professor Erik Meijer in this context and professors answer the questions of their students. Thank you, Erik, for doing this!

Welcome to C9 Lectures!

Rating:
36
0

Sweet -- will watch when I get back from work.  But it's "lambda"  Tongue Out

exoteric
exoteric
I : Next<I>

Pure joy! Smiley ... Another two books in the basket. Thanks for the discount.

keithfl
keithfl
keithfl

Awesome! Awesome! Awesome! Big Smile

 

What an awesome idea! ... I'm surprised Eric has time to do this ... but glad he did!!! What a service for the .Net dev community!  I have friends (and me too!) who've bought books about functional programming and have not been able to get through them. This however, is just what is needed!!! FP is obviously a big deal and growing in importance .... mullticore, languages like Scala, FSharp and even CSharp.

 

There's a ton of other guest lecturers I would like to hear .... Andrew Kennedy, Simon Peyton Jones, Don Syme ... I'd love to hear Joe Duffy talk about using FP to enable Paralell Extensions for .Net!! The mind boggles ...

 

Thanks MS, thanks Charles and thanks Eric!!

 

PS: One request ... I havent listened to the recording yet ... however, it would be great if some of the examples were done in FSharp (rather than Haskell) only because quite a few of us are likely to actually use FSharp for work at some point and I doubt many folks are gonna use Haskell for any real work anytime soon ... just my 02 cents.

exoteric
exoteric
I : Next<I>

It's probably better to use a pure language to explain pure mathematical functions.

exoteric
exoteric
I : Next<I>

Need to come up with some questions but first I stumbled upon this presentation of Clojure on YouTube (not because of some special interest in Clojure as much as some concepts presented by its inventor recently.) The presenter tries to explain functional programming. On the first point he writes "functions are first-order"; it sort of jumped out because actually what I'd expect was: "functions are values", therefore higher-order functions are a consequence of this; higher-orderness is possible because functions are values.

 

Speaking of object-orientation, I remember several years ago Java and similar languages being presented as higher-order typed languages (HOT), meaning functions (methods) in these languages were also higher-order because one can pass in objects and these objects can contain other functions (methods) and so in practice one almost ends up with the same "effect". Of course then we have all the dirty side-effects of mutating objects passed into other objects, unless the objects themselves come from classes that are defined as immutable; in a way immutable objects are still-born: after construction they are immutable and become lifeless - and when stopped being used anymore the holy garbage collecter carries the object identity into oblivion.

 

One question: would you say this sums up (one of) the selling point of purity and laziness: laziness without purity is dangerous (unpredictable side-effects) whilst purity without laziness is slow (repeated evaluation). It's like "bounded computations" you may not know what's in the box (it's black or your vision is) but you can be sure that whatever is in the box does not escape it (not through the front door (the argument list); nor through the backdoor (the return value)). In effect a prison for sinful computation. Another selling point being compositionality.

 

And on expressions vs statements. One thing I seriously miss in C# is having expressions everywhere; for example if is an expression and a {} block is an expression, evaluating to the last expression in the block. To get around this one can use the e?a:b expression pattern. Same for switches. Erik showed "iteration" in Haskell using list comprehension (I believe). In C#, I'd use Enumerable.Range(i,n). It's a more disciplined approach but if discipline is all you have, it'll come natural.

 

Appropos "weird" encodings of pure functions.

 

(PS - The triangular operator mentioned is the forward pipe operator |>; love that, as well as the >> right composition operator.)

Microsoft Communities