[Haskell-cafe] Re: Some Haskell platformish questions
niko.korhonen at gmail.com
Thu Aug 2 06:28:59 EDT 2007
My answers apply to Windows/GHC.
David Pollak wrote:
> * Can GHC generate stand-alone executables with all the dependencies
> linked in such that I can distribute the single file without
> worrying about including a bunch of DLLs/SOs? The answer seems to
> be yes, but I wanted to confirm.
> * How much of a distribution footprint is the Haskell runtime? If I
> have a "Hello World" app, roughly how big will the EXE be (if one
> includes the JRE in the runtime, a Java/Scala program has a
> minimum footprint of 20M... that's big.)
A hello world application executable on Windows/GHC 6.6.1 is 592,385
bytes. But the size grows very quickly to 1-2 MB when you start
including the basic libraries.
> * Same goes for the runtime... I've looked at the stats on the
> Language Shootout home page and these look encouraging, but I
> wanted to see if the reasonable footprint is a reality.
The memory footprint of a well-written Haskell program seems to be very
small. I once wrote a text parser that only used a maximum of 2 MB of
memory while processing an infinite stream. This is much less than the
minimum footprint of the JVM. One reason for this is that the GHC
garbage collector officially kicks ass.
However, it is exceedingly easy to write memory-leaking programs in
Haskell. Fortunately memory leaks usually manifest themselves as a
program crash (stack overflow) or very high heap usage (easy to monitor
in task explorer). In any case, the memory usage is pretty easy to
monitor with GHC's built-in profiling facilities.
Now fixing Haskell memory leaks... a completely different story. It's
nothing short of black magic. Performing the simplest program
optimizations and fixing the simplest of memory leaks generally requires
a level of gurudom that is not even possible to achieve just with
Fixing a Haskell program usually involves performing a couple of sacred
rites, sacrifices, voodoo rituals (you can consult your preferred deity,
it doesn't matter). When that doesn't help, approach the Gurus of this
forun, place the ritual Offering and plead for help. If they are
satisfied with you, they might, just might, throw you a scrap of wisdom
from their infinite mental capacity, which upon receiving will shock and
humble you for life. Usually it sounds like this:
"Here's a one line fold that replaces your entire program and doesn't
have the memory leak."
> * I tend to do most of my coding in either Emacs or Eclipse... how's
> the Haskell support in either? Is there a preferred editor (I
> don't mean to start any wars here... :-)
Yes, there's a plugin for Eclipse. It's actually slightly better than
the Scala plugin you're probably familiar with :)
There's also a good syntax highlighting file for jEdit.
More information about the Haskell-Cafe