large binaries

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Wed, 24 Jul 2002 10:55:38 +0100


Jon Cast <jcast@ou.edu> writes:

> > It would not be entirely fair to lay all the blame for large Haskell
> > binaries entirely at the door of static vs. dynamic linking.
> 
> Well, considering that compiling the C binary statically linked
> produces an even bigger executable:
> 
> $ gcc -static hello.c -o hello_c
> $ ls -l hello_c hello_hs
> -rwxrwxr-x    1 jcast    jcast      441624 Jul 23 20:56 hello_c
> -rwxrwxr-x    1 jcast    jcast      157028 Jul 18 14:08 hello_hs

You aren't comparing like with like here.  Your hello_c is statically
linked with libc, but hello_hs is dynamically linked with libc.
Here's what they look like on my machine:

    13220  hello_c   dynamically-linked
   481503  hello_hs  dynamically-linked

  1444114  hello_c   statically-linked	(gcc -static ...)
  1958990  hello_hs  statically-linked  (ghc -optl-static ...)

> > In fact, most of the extra stuff in "Hello World" is there purely to
> > handle all possible error conditions in the I/O monad.
> 
> You mean as opposed to C, where most of the extra stuff is there
> purely to support number formatting?

Ok, point taken.  There is a lot of code re-use in both languages.
But because Haskell is higher-level, it tends to re-use the lower-level
C library in addition to its own libraries.  That is all.

Regards,
    Malcolm