[Haskell-cafe] Some random newbie questions

O.Chitil at kent.ac.uk O.Chitil at kent.ac.uk
Fri Jan 7 06:37:14 EST 2005

> * What are the relative advantages of Hugs and GHC, beyond the obvious
> (Hugs
>   is smaller and easier for people not named Simon to modify, while GHC is
> a
>   real compiler and has the most up-to-date hacks to the type checker)?
> Do
>   people generally use one or the other for everything, or are they
> similar
>   enough to use Hugs at some moments and GHC at others?

I just completely redesigned our first year undergraduate Haskell module
and considered moving from Hugs to GHC. Because most students have Windows
at home I don't consider installation a problem for GHC. GHC is the
compiler for serious Haskell development. While this is not needed for
beginners, I believe it demonstrates better to students that Haskell is
not just an academic toy language. The error messages of GHC are generally
better than those of Hugs; unfortunately GHC produces very bad parse
errors and beginners tend to make lots of those (however, Hugs has the
infamous unexpected semicolon error message). Hugs stops after the first
error message, while GHC usually reports many errors. I think that for
beginners the long list produced by GHC is more frustrating and they only
repair one error at a time anyway. Hugs is also quicker in reporting an
error. I also do not like that GHC exposes non-Haskell 98 features: if you
type :t length you get length :: forall a. [a] -> Int. "forall" is not
Haskell 98. So because of such a list of slightly beginner-unfriendly
features I decided to stay with Hugs for this year. I might revise this
next year, especially if GHC improves (I should ask Simon&Simon about
these issues...)

I also like the built-in HOOD of Hugs that makes "observe" polymorphic.
However, I'll probably give up my original plan of using it in lectures to
observe functions and thus get a better intuitive feeling for functions as
mappings from inputs to results.

> >   I've clearly got a lot to learn about space usage in Haskell... can
>   someone give me a hint about what is the problem here and how it might
>   best be corrected?

I'm glad to see Ross' explanation that the space problem is caused by the
library, because your code looked fine to me.

I'm constantly surprised hearing from so many people about their space
problems. I cannot remember having space problems with my programs. I
don't know what everybody else is doing wrong :-) I do disagree with
people recommending strictness annotations (seq etc). In contrast, I make
my programs as lazy as possible.

Actually I just remember once adding 'seq' to my pretty printing library
to ensure it had the space complexity I wanted (not that there was a
problem in practice). However, shortly afterwards I realised that I could
rewrite that part in a way that made 'seq' superfluous, was shorter,
nicer, and probably even slightly more efficient.


More information about the Haskell-Cafe mailing list