Navigation bar
  Print document Start Previous page
 11 of 21 
Next page End  

Transcription by PWOP Productions, http://www.pwop.com
Page 11 of 21
Simon Peyton Jones on Haskell and Functional Programming
January 24, 2008
Richard Campbell:
And that's declarative.  You're
saying, "This is pure."  You know for sure that it's got
no dependencies.
Simon Peyton Jones:
And it says it in its type, it
wears it on its sleeve as it were.  If it has type IO of
int, then in the type it says, "I take an int and I
produce an int, but on the way I might do some input/
output," and that includes side effects and mutable
variables.
Richard Campbell:
Right.  So, again, the OS is
able to see this might have some dependencies.
Simon Peyton Jones:
Right.
Richard Campbell:
I guess this is an interesting
side effect of laziness is that because you don't
compute things until you need them you have no way
of knowing unless you can see them right upfront.
Simon Peyton Jones:
Say that again?
Richard Campbell:
I'm thinking this is the strength
of Haskell.  This laziness approach gives us the ability
to -- we don't know what that's going to compute until
we absolutely need it so you have to have that sort of
independency.
Simon Peyton Jones:
Right, yes.  So that's the
reason that Haskell is the purest of the functional
languages compared to, say, Lisp or ML or F# or
CAML, all of which have side effects in the base
language and any function can cause a side effect at
any time.  Haskell has retained the kind of forced
purity precisely because laziness means that if you
have this, let's say our big tree, if those trunks in the
tree could do IO, could write mutable variables or shut
down your system or switch on the lights, well, you
wouldn't know when the lights will get switched on
because it would depend on when the consumer of
that tree pokes to them, right?
Carl Franklin:
Right.
Simon Peyton Jones:
So because the order of
evaluation is somewhat hard to predict, it makes it
essentially infeasible to write programs that usefully
just have side effect occurring anywhere.  So, that
forced Haskell to stay pure and that led us to invent a
way that these monad stuff of allowing you to mix
purely functional programming with mainstream
imperative programming without the two screwing
each other up.
Carl Franklin:
Do you know the perfect
formula for building and managing websites?  Follow
me here.  Zero effort plus Sitefinity CMS = infinity in
website development.  That's right.  Telerik
challenges you to explore its innovative Sitefinity
Content Management System and it offers you a
chance to win a sleek Zune MP3 player or a Sitefinity
license.  These cool awards could be yours if you only
answer a few easy questions about Telerik's Sitefinity
CMS.  All you have to do is watch five short movies
and see how easy it is to build infinitely beautiful
websites with zero effort.  You'll learn some cool facts
about Sitefinity and the effortless creation of websites. 
So, go to www.sitefinity.com and give it a try.  It's fun,
it's interesting, and it can get you a free license or a
free Zune.
Well, you brought that up twice now, this monad thing. 
So, why don't we just go down that rabbit hole?
Simon Peyton Jones:
Okay.  The worst thing
about monad is the name.
Richard Campbell:
They sound far worse than
they are.
Simon Peyton Jones:
Yeah, that's why.  The
name is very off-putting because it comes from
something mathematical.  I'm on record as saying we
should have called them warm, fuzzy things.
Richard Campbell:
Because they're good.  They're
really good.
Simon Peyton Jones:
They are really good and I
think we're going to see some flavor of monads, they
won't be called monads, in more mainstream
languages because in effect it's a way of explaining
when functions have side effects.
Richard Campbell:
Right.
Simon Peyton Jones:
So, let me put it like this. 
Let's see.  Take a while loop in C.  In the curly braces
of the While loop, there's some imperative stuff, "Do
this and then do that."  The while loop is a language
construction, again, known to the compiler which
repeatedly does that stuff.  Okay?
Richard Campbell:
Yeah.
Simon Peyton Jones:
But that stuff is not a value
that you can pass around.  You can't store that stuff in
a data structure.  You can't say X {bubble bubble and
then later say "while X..."
Richard Campbell:
Yeah.  No, you can't do that.
Simon Peyton Jones:
Or "While condition, do
X…"
Carl Franklin:
Yes.
Simon Peyton Jones:
Meaning "do this stuff;" but
imagine a situation in which these curly braces, this
Click to Convert - Powerful PDF Converter and HTML Converter.