[Haskell-cafe] In-place modification
sebastian.sylvan at gmail.com
Sun Jul 15 08:11:38 EDT 2007
On 15/07/07, Hugh Perkins <hughperkins at gmail.com> wrote:
> On 7/15/07, Donald Bruce Stewart <dons at cse.unsw.edu.au> wrote:
> > In this case it is fine. You're setting bits in the cache. Please use the
> > same algorithm, or any conclusions are meaningless.
> No, I'm counting prime numbers. Somewhat faster it seems ;-)
> Let's put this into the real world a moment. You get a job, or you're at
> your job, you spend several weeks writing some super-dooper program, telling
> everyone how awesome it is because it's Haskell and it's l33t!
> You run it, and it takes 24 hours to run. It's ok, it's Haskell.
> Some guy with long hair and no degree comes along, and rewrites your code in
> C#. Takes him like 30 minutes because he doesnt have to optimize it, it's
> done automatically.
> His program runs in 25 minutes (60 times faster, see the benchmarks above to
> note that this is realistic).
> Guess who gets fired?
Oh come on!
If you really want to calculate how many primes there are in 32 bits
int you would precalculate it in a table.
This *isn't* a real world application! Stop pretending it is! If you
want to compare various features of the languages to see how they fare
you need to use fair comparisons!
So two options if you are really interested in knowing how fast
Haskell is compared to C# (and I think it's becoming clear that you're
not, so why bother?):
* Write a real application. Not some micro benchmarks that is
essentially assembly level programming. Btw, If this sieve program is
representative of how most of your C# programs look, I'd wager you are
the one who will get fired! This program isn't C#. It doesn't use any
of the neat C# features. It's essentially C, in C# syntax. How does
that say anything about the /general/ speed of C# versus Haskell?
* Try micro benchmarks of various different features. For example
write a sieves version using lazy streams to see how fast lazy streams
are. As I've demonstrated, Haskell is quite a bit faster there (see my
C# implementation of the original Haskell code). The important thing
to note here is that you are comparing *specific* features of the
language. Changing the algorithm in one language but not the other is
For the latter you can always consult the shootout:
Looks like Haskell doesn't fare to poorly against C#.
More information about the Haskell-Cafe