[Shootout-list] Re: Optimizing for speed vs. beauty

John Goerzen jgoerzen@complete.org
Thu, 30 Sep 2004 10:30:56 +0000 (UTC)


On 2004-09-30, Brandon J. Van Every <vanevery@indiegamedesign.com> wrote:
> John Goerzen wrote:
>> Brandon J. Van Every wrote:
>>
>> > You can't put a number on
>> > beauty, unless you're into gratuitous lying.  Aside from
>> > beauty being in
>>
>> The lines of code is a number that's there and close.
>
> Well, I'm of the camp that LOC is a big, ancient lie.  For instance, all

Regardless of that, it *is* telling.  For instance, at [1], I observe
that Haskell can use one line of code to do a job that takes 11 lines of
C or 15 lines of Java.  Oh, and Python can do it in 2 lines.  That tells
me something right there.  Right off the bat, I get this gut feeling
that Java sucks for I/O.  And sure enough, it does.  While some people
complain that I/O in Haskell is complicated, it's got nothing on Java.

>> I don't think so.  So much effort is spent on optimization that the
>> resulting code is such that it would rarely be used in actual practice
>> in many cases,
>
> Whose actual practice?  I can assure you that for people who need to
> implement performance loops for their apps, the faster snippets are
> valid!

I'm talking about learning about the different languages.  If you're far
enough advanced in a given language to be ready to learn about
performance hacks, you don't need a resource like this to show you the
language in the first place.

> If there's a specific language you want people to learn, a website

No.  I want to learn as much as possible about as many languages as
possible, so I can make the best possible choice for each particular
project.

> dedicated to that language is adviseable.  Why learn all of 'em?  I'm

Because they have unique strengths and weaknesses.  My daily arsenal
includes Python, OCaml, and shell.  However, I do reach out to Java, C,
PHP, Lisp, and occasionally Perl for other tasks.  And I think I will be
adding Haskell to my daily arsenal.

I recently re-implemented a website.  I used PHP for it.  I hate PHP the
language.  But PHP the system and PHP the community are excellent for
that sort of thing, so although the lack of warnings about typod
variable names makes me cringe, I got it done a lot faster than I would
have had I used Python, OCaml, or C.

> all for marketing / advocating specific languages, but if you've
> followed ocaml-biz at all lately, you'll realize I think there are
> better tactics for evangelizing any one specific language.  Like,
> devising a benchmark that favors your language, pitting your strengths

Did I hear you right?  "Devising a benchmark that favors your language?"
How is that anything but misleading, if not outright fraudulent?

Such a device will only gain you converts from those not smart enough to
see through your little ploy.  You probably don't want those people
anyway.

> against your main competitor's weaknesses.

How about an honest comparison?  After all, if your language fails that,
maybe you need to find a different one.

> I stick around the Shootout because I'm interested in questions of
> Performance generally, not any one language per se.  I've always been a
> Performance guy.  In fact, the orginal Shootout is what led me to OCaml
> in the first place.  Revived, it could lead me somewhere else.

The original shootout did lead me to OCaml in the first place too.  But
not because of the performance (well OK, there was some pride in seeing
a functional language kick g++ around), but because of the elegance.

> There isn't one.  Much as I don't belong on caml-list because I'm not a
> UNIX techie PhD language wonk, you're barking up the wrong tree wanting

Neither am I, but I fit in there just fine.

Perhaps you don't belong on ocaml-list because you expect a bunch of
Unix users to port something to an operating system they hate just
because you gripe about it?

> How do you 'shoot out' beauty anyways?  Endless debates of my idiom is
> better than your idiom?  Recursive algorithms considered cute and all of
> that?  I've done and seen plenty of that on caml-list.  Sometimes it's
> interesting, often it's boring, and frequently it pisses people off.

No, the idea is not to cause debate, but to show people options and let
them decide for themselves.

The Perl folks can make great use of $_ and other implicit tricks.  The
Haskell folks can make use of lazy I/O.  The Python people can use
objects.  The Java people are SOL :-)

> What are you going to do when the first Perl programmer shows up and
> says you're full of s**t?  Try to get the Python guy to fight it out

No, you write the Perl program to show off the Perl way, and the Python
program to show off the Python way.  They're different, of course,
because The Way is different.

[1] http://shootout.alioth.debian.org/bench/sumcol/?loc