[Haskell-cafe] Cyclic Inclusions

ajb at spamcop.net ajb at spamcop.net
Tue Aug 12 23:06:48 EDT 2008


G'day all.

Quoting Thomas Davie <tom.davie at gmail.com>:

> Why is separate compilation important?

I'm a little shocked that anyone on this list should have to ask this
question.  Two people have asked it now.

The simplest answer is that unless your program fits in cache, it
takes longer to compile two modules concurrently than it takes to
compile them separately.  This is even more true if one of those
modules does not actually need recompilation.

The longer answer is that in the Real World, programmer time is
far, far more precious than computer time.  Every second that the
programmer waits for the computer to finish some task, there is a
priority inversion.

It's therefore highly desirable that jobs done by computer are as
fast as possible or, failing that, as predictable as possible, so
the programmer knows to do something else while waiting.

Separate compilation puts a predictable upper bound on the amount
of recompilation that has to be done given some set of changes.
True, so does requiring recompilation of a package as a whole, but
Haskell development would then be notorious for its sluggishness.

> I can understand your point
> about a module on it's own not being analyzable, and that that's an odd
> property -- on the other hand, the rapidly emerging "atomic" unit in
> Haskell is the package, so I see no reason why modules within one
> package shouldn't depend on each other.

Implicit in my working definition of "module" is that a module has a
well-defined interface.  Am I the only one who has that understanding?
(Well, me and David Parnas, at any rate.)

For the record, I have no problem with modules depending on each other,
so long as they only depend on their well-defined interfaces.

> Finally, as chris suggests, if separate compilation is important to
> you, why not have a flag in ghc -frequire-hi-boot or something?

Well, if I wanted separate header files, and the inevitable multiple-
maintenance headaches associated with them, I'd program in C.  Except
for mutually recursive modules, GHC can and does generate header files
automatically, so I don't see why my time should be wasted doing the
job of a compiler.

If something is preventing the compiler from doing that job, then that
something should be fixed.

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list