| In that regard, I think the biggest problems remaining are the lack of a
| standard "fast" string type, and some remaining warts in hugs. These are
| maybe easiest to see when you do something like "strace -c" on a hugs
| program and the comparable perl program. So, in my naive version of
| "hello world", the hugs version generates 803 calls to 'lstat', 102 calls
| to 'stat', and a performance-killing 13 calls to 'write'; yup, that's
| one for every character. :-( throw most of those out, and you're within
| shouting distance of perl. And that would be something to shout about.
I see big problems in using Hugs as an example in discussions about the
speed of compiled code. Hugs derives from Gofer, which was designed to
fit on a 16 bit machine with a fairly small memory (several times smaller
than the PDAs, digital cameras, and video cards in use today). It was
also designed, from the beginning, to be an interactive system based
around a simple read-eval-print loop. Performance was never the priority.
After all, there were a couple of other places you could turn for a compiler
if you did want performance, and those folks had spent a lot of time and
effort on building their systems. Hugs was intended to complement rather
than compete with them.
Because interactivity was a goal, Hugs, by default, does indeed call
fflush after every character, which causes the repeated calls to write
that you see. If it didn't do that, then programs on slow machines or
with expensive underlying computations might have behavior that is counter-
intuitive and confusing, especially to beginners. We are, after all,
talking about a lazy language, and so you wouldn't think that you'd have
to wait for a whole line of output before you saw the first character.
Surprisingly, perhaps, the performance of Hugs turned out to be good enough
for many tasks, particularly on the machines that we use today, and so
tools like runhugs have become a viable option for some purposes. But you
should always remember that Hugs came before runhugs, and that the default
distribution is tuned primarily for use as an interactive environment.
There is, in fact, a compile-time setting that you can use to prevent
Hugs from calling fflush after every character (I think it's FLUSHEVERY,
but you should check). If you set that appropriately, then Hugs I/O
will (or should) run a little more quickly.
All the best,
Mark
----------------------------------------------------------------------------
[EMAIL PROTECTED] Pacific Software Research Center, Oregon Graduate Institute
Looking for a PhD or PostDoc? Interested in joining PacSoft? Let us know!