[Haskell-cafe] Re: Tutorial on Haskell
apfelmus at quantentunnel.de
Mon Apr 16 10:55:03 EDT 2007
Simon Peyton-Jones wrote:
> I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007
> I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk,
> many of whom won't know much about Haskell. My guess is that they'll
be Linux/Perl/Ruby types,
> and they'll be practitioners rather than pointy-headed academics.
> One possibility is to do a tutorial along the lines of "here's how to reverse a list",
> "here's what a type is" etc; you know the kind of thing.
> But instead, I'd prefer to show them programs that they might consider
> rather than cute, and introduce the language along the way, as it were.
> Remember, the goal is _not_ "explain monads".
> It's "Haskell is a great way to Get The Job Done".
While this it not a concrete suggestion for an example, I'd like to say
why I can't help but program in Haskell: it gives me power. Programming
in Haskell is like dual-wielding two light sabers whereas programming in
imperative languages is like being equipped with a blunt kitchen knife.
Sure, cleverly used, you can dissect problems with the knife but the
light saber will disintegrate them instantly. If I were to give a
tutorial, I would concentrate on showcasing such power.
My current favorite example of power is the k-minima problem that has
been discussed on this list:
take k . quicksort
Why is this program correct? Because it's almost the problem
specification and because the type checker accepts it. But is it fast?
Sure it is, because lazy evaluation does miracles (at least here ;).
What else? The sugar on top is that this program is polymorphic.
The above example is probably not considered "useful". To me, useful =
asymptotically fast algorithm for a difficult problem, and I'm always
astonished how incredibly easy it is to formulate or even derive a
Haskell program that introduces the missing logarithm. But somehow, the
word "performance" that people cry for doesn't seem to be related to
that. At least, that's the impression I get when experiencing the
sluggishness of certain programs.
Anyway, maybe a showcase of power would be if the talk talks about how
to create talks in Haskell, especially the talk being held. I mean that
the showcased example could be to build a small type-setting/graphics/PS
or PDF system in Haskell from scratch that is capable of producing the
slides for the talk itself. This would include
* a simple dynamic programming type-setting algorithm
* a simple, preferably external (XMl, Parsec, ...) language for
describing slides with some macro capabilities (like variables
and substitution, perhaps even recursion or loops, slide numbers!)
* a small vector graphics library (for text and a few visual gimmicks)
that can output to PDF (or PostScript for simplicity).
(polymorphism: one API, different backends).
The point is of course: "With Haskell, I'm not only able to create my
slides from scratch, but I can even completely explain the code to you
in only 3 hours!".
More information about the Haskell-Cafe