[Haskell-cafe] Non-technical Haskell question

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Tue Dec 7 04:53:05 EST 2004

> > > >  When I compile it I get three files, an actual runnable binary (at only
> > > > 5M in size), a .o file and a .hi file. I'm sure these additional files
> > > > are usefull in someway and as soon as I come across the right piece of
> > > > documentation everything should make sense. But as a person new to the
> > > > language I'm just left wondering why.
> > javac often creates tens or hundreds of .class files, some with
> > strange names like MyClass$1.class, MyClass$2.class, and so on (yes, I
> > know what they are for), and doesn't even generate a native binary.
>  When I use javac every file that is created is necessary for the
> application to run. This can't be said of the ghc compiler. Having an
> excuse that this is way the C compiler does it or that this is the way
> its always been done is to poor of a reason to even argue against. If a
> file isn't needed then it shouldn't be left there. 

This isn't really true for Java either.  You surely don't intend to
distribute your app as a bunch of .class files - you distribute the
.jar file.  The .class files are just intermediate files that javac
leaves lying around; and javac isn't even capable of building the .jar
itself!  You have to use a separate utility.

Just think of ghc as a combined javac and jar, the .o files as .class
files, and the executable as a .jar.  In fact, this is how ghci treats
.o files - it loads them as needed, in a way not that different from
the Java VM (except that of course .o files are native, not bytecode).

Anyway, this has already descended into advocacy, and I'll stop here.

--KW 8-)

More information about the Haskell-Cafe mailing list