[Haskell-cafe] In-place modification

ok ok at cs.otago.ac.nz
Wed Jul 11 19:29:25 EDT 2007

On 11 Jul 2007, at 9:56 pm, Bulat Ziganshin wrote:Java comes close to  
being competition, but it's slow and eats memory
> never checked it myself, but people say that modern Java
> implementations are as fast as C# and close to C++ speeds

People will say anything, but before believing this particular
one you will have to do your own measurements.  Here's mine:

I'm one of two lecturers in a 4th year information retrieval paper.
The main programming exercise is one where the students write their
own simple IR engine.  It's really pretty simple.  My model answer
in C is two separate programs, an index builder and a query engine,
and is 804 SLOC in 1075 total lines.  Each year, despite our advice,
some student does it in Java.  I have one such from last year:
1611 SLOC in 2531 total lines.  (Yes, this does mean programmer X
writing C can be twice as productive as programmer Y writing Java.)
The real killer is performance:  the Java program is 150 times slower
than the C one.  Let me say that slowly:  one hundred and fifty times
slower.  What was that about "close to C++ speeds" again?

The reason I have the program is that the student was distressed by
this and wanted me to help.  The problem was the Java libraries, one
class in particular.  By replacing that class with home brew code (at
the cost of several days coding and experimenting) it was possible to
speed the Java program up by a factor of about 15, at which point it
was *still* slower than AWK (using 'mawk 1.3.3').

I mentioned this in another context, and got a reply from someone who
has worked on large commercial projects in Java, who said that typically
half of their code was application-specific and half of it was rewrites
of Java library facilities to work around serious performance problems.

The lesson here is that productivity and performance are NOT solely
a matter of language; they are also a matter of libraries.  The Haskell
language is wonderful and I enjoy experiencing the reality of "there is
nothing as practical as a good theory".  But if we just had the
Haskell 98 report and libraries, it would NOT be a productive tool for
many real problems.  The growing collection of amazing stuff in the
hackage collection is extremely important.

More information about the Haskell-Cafe mailing list