[Haskell-beginners] A Comparison of Haskell and Scheme

Albert Krewinkel krewinkel at gmx.net
Tue Feb 10 03:30:40 EST 2009


Benjamin L.Russell <DekuDekuplex at Yahoo.com> writes:

> Although somewhat dated (posted on October 24, 2006 4:39 PM, to be
> precise), here is an interesting comparison of Haskell and Scheme, by
> Mark C. Chu-Carroll, a PhD computer scientist who works as a software
> engineer at Google, on his blog, regarding whether someone should
> translate Douglas Hofstadter's columns introducing Scheme to replace
> the Scheme code with Haskell code:
>
> Good Math, Bad Math : Haskell and Scheme: Which One and Why?
> http://scienceblogs.com/goodmath/2006/10/haskell_and_scheme_which_one_a.php
>
> The entry discusses differences in syntax, typing, and semantics, and
> makes for interesting reading.

I've got a question related to comparison of Haskell and Lisp.

I just learned some basics about category theory and therefore started
to learn some Haskell, too.  Currently I'm doing most of my hacking in
lisp (to be precise: the probably unpurest language out there, Common
Lisp), so please excuse my ignorance as I'm try to change this.

Of what I've seen so far, I'm very fascinated by the power and elegance
of Haskell.  I read a few short introductions on Monads, getting a
glimps of easy DSL developing in Haskell.  In Lisp, one would use the
macro system to achive this.  Even though the concepts seem
fundamentally different, I was wondering if there are any parallels?

Also, could someone point me to a gentle introduction to syntax,
semantics and type systems?  I understand that lisp-like macros do not
exist in Haskell since they would break the type system and could give
rise to unclear semantics.  I'd like to understand what's going on, so
pointers to books or tutorials would be highly appreciated.

Thanks
Albert

> Surprisingly, he states that Haskell
> syntax is easier to learn for beginners:
>
>>I've actually taught an introduction to computer class using Scheme, 
>>and the syntax was a big problem.
>>
>>I think that syntactically, Haskell is a better language for beginners. 
>>Haskell syntax is very redundant, which is good for people. Compare 
>>these two little snippets:
>>
>>(define (fact n)
>>    (if (= n 0)
>>        1
>>        (* n (fact (- n 1)))))
>>
>>fact n = if n == 0
>>        then 1
>>        else n * fact(n-1)
>>
>>Which is easier to read? And the Haskell can get even easier to read 
>>and write using pattern matching:
>>
>>fact 0 = 1
>>fact n = n * fact (n-1)
>>
>>Try this comparison:
>>
>>(define (fold init reducer list)
>>    (if (eq? list ())
>>        init
>>        (reducer (car list) (fold init reducer (cdr list)))))
>>
>>versus:
>>
>>fold init reducer [] = init
>>fold init reducer l:ls =  reducer l (fold init reducer ls)
>>
>>The difference gets much more obvious with bigger pieces of code. 
>>Between the deliberate redundancies in Haskell's syntax, and the way 
>>that pattern matching lets you decompose programs, the Haskell is 
>>significantly clearer.
>
> This is the first time that I have seen a claim that Scheme syntax was
> a big problem compared to Haskell syntax, but his claims make sense.
> It makes me wonder whether his students were true beginners....
>
> If his claims are true, though, then we probably need a counterpart to
> SICP (see http://mitpress.mit.edu/sicp/) for Haskell.  The closest I
> can think of is SOE (see http://www.haskell.org/soe/); any
> alternatives?  There's also _The Haskell Road to Logic, Maths and
> Programming_ (see http://homepages.cwi.nl/~jve/HR/) and _Real World
> Haskell_ (see http://book.realworldhaskell.org/), but the former is
> really about using Haskell to learn discrete mathematics and logic,
> and the latter is not directed toward computer science majors, so they
> don't correspond very closely.  If Haskell is well-suited as a
> language for beginners, then there shouldn't be any reason for not
> creating a Haskell alternative.
>
> -- Benjamin L. Russell


More information about the Beginners mailing list