[OT] Teaching Haskell in High School
Michael Sperber [Mr. Preprocessor]
sperber@informatik.uni-tuebingen.de
Fri, 07 Feb 2003 09:42:10 +0100
>>>>> "Paul" == Paul Hudak <paul.hudak@yale.edu> writes:
Paul> I can't resist jumping in on this one:
Sure :-)
>> Haskell just has some terrible properties when it comes to teaching
>> beginners. Among them are the complex and easy-to-get-wrong syntax,
>> the available programming environments which are OK for developers but
>> awful for beginners. There's also a dearth of good textbooks at the
>> level you need. Haskell is very easy to learn (and an excellent
>> choice for a 2nd or 3rd language) when you know Scheme.
Paul> I have spent many years teaching both Scheme and Haskell to beginners,
Paul> and I would have to say that Haskell syntax has never been a serious
Paul> problem, certainly no more than Scheme's parentheses. It is true that
Paul> there is a lack of good programming environments, although Hugs is
Paul> pretty easy to use, and things like Helium should be even better. (I
Paul> won't say much about textbooks since I wrote one that I think is pretty
Paul> good for beginners :-) Finally, aside from extraneous type error
Paul> messages (which Helium should do much better at), I claim that Haskell's
Paul> type system is BETTER for beginners compared to having no type system at
Paul> all. As for the last point above, I could just as easily say that
Paul> Scheme is very easy to learn (and an excellent choice for a 2nd or 3rd
Paul> language) when you know Haskell.
Here are some observations I've made when teaching Haskell for the
first time which are relevant when you're trying them out on
beginners:
- With the programming environment, it isn't just a question of being
"easier to use": in my experience, environments like Hugs (or any
Scheme environment other than DrScheme) work for some, but frustrate
many beginners because they don't enable them to fix trivial
mistakes which they're bound to make in the first couple of weeks.
These are *crucial* to the overall success of an intro course.
The TeachScheme! folks had to work a long time on getting DrScheme
to provide the feedback needed to alleviate this problem. Haskell
systems just don't have this kind of investment. (I'm glad Helium
showed up, and I'm sure to try it out soon.)
- In theory, static typing is good because it helps spot bugs in your
program early. However, the current state of the art is such that
the type error messages in Haskell systems are not sufficiently
helpful (in fact, often misleading) when it comes to finding the
actual source of the problem. You're saying "aside from extraneous
type error messages"---but these are *exactly* the problem.
Certainly, the messages from Hugs and GHC often frustrate beginners
(and not just beginners in programming---I've seen quite a few
students who were learning Haskell as a 3rd or 4th language give up
because of this).
Again, Helium may be an improvement, but I suspect that the
underlying problem is deeply rooted.
- I've written between 10000 and 100000 lines of code in Haskell, and
I still do things like:
- look up syntax in a book
- getting the alignment wrong
- using a name twice in a recursive let, leading to infinite
recursion
Scheme syntax is just *way* smaller than Haskell syntax, and, while
it may not constitute a serious problem in any given course, it
certainly eats up less space when you explain it. Here are some
other aspects of Haskell syntax which---in my experience---are
confusing for beginners:
- The syntax for ordinary variables and type variables are the same.
In fact, many examples by Great Haskell Programmers use a variable
"s" (for instance) to denote a value of type "s". Beginners often
have trouble understanding and distinguishing the concepts of
variables and type variables, and this makes it worse.
- The same holds generally for the type syntax which is analogous to
the value syntax.
- I don't know what kind of beginners you're talking about exactly.
The original poster was asking about high school. With *CS*
beginners (or beginners in some related field) different rules apply
than for the average population. If these kids have problems early
on, they're just bound to leave programming and never come back (or
much later).
I'm sure some of you have didactic concepts to get around these
problems---but, as you mention, they sure aren't published anywhere,
much less in a comprehensive form as HtDP, and the tools don't exist
with the same quality as DrScheme.
There's much more to say---about things like motivating examples with
GUIs and web servers---which DrScheme has in a form accessible to
beginners, but you can all read up on that in the TeachScheme!
material.
Haskell has great potential to be a wonderful and useful language for
software development and research.
It often pains me to see the efforts of the functional programming
community (which is small enough as it is) fragmented by the "My
language is the best for *everything*" attitude. For intro teaching,
the TeachScheme! have *done* so much work on teaching functional
programming not available for Haskell, and I wish the Haskell (and ML
and ...) community would just reap the benefits rather than doing the
usual NIH thing.
--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla