in reply to Just thinking ...

In reading the comments already posted, I think we need a new word other than beauty. Half of these posts stumbled off-topic a bit to coding-style rather algorithm beauty. Personally I find merlyn's coding style a bit ugly but the algorithm is purty. =)

I like what princepawn is doing with his logic stuff and the constants stuff especially. But I find it even uglier.

mirod's rant saved me from writing the same thing =)

My dad once said, "There is all kinds of good looking, but there is only one kind of ugly." Now he was talking about dogs or cars or something but it is kind of true here. I see lots of great ways to express the same task, clearly and in a mostly self-documenting way. And a lot of them just moved the ugly out of sight. =) But for all those cases, the algorithm is generally non-ugly. Most of what I see is just different ways to decorate the dog.

Oddly, I was just working on a Cache module for a nasty little web problem I have. I have a hidden webserver that only my public webserver can speak to, generating graphs on that second machine. In an effort to not beat the hidden server to death (it has to do real work too) I want to cache the images locally. Rather than run a cache on the hidden machine (eek, memory) or a reverse cache on the public machine (eek only helps with the http and not the other protocols I have to get working next) I did a the next best thing. I threw Perl at it. =)

What I got was this:

use DiskCache; my $xdc = new DiskCache "image", 300; if ( $xdc->exists( "filename.ext" ) ) { print $xdc->get( "filename.ext" ); } else { $xdc->del( "filename.ext" ); my $newdata = GetDataFromSomeWhere(); print $newdata; $xdc->put( "filename.ext", $newdata ); }

Now that I've seen merlyn's stuff I suppose I'll have to do it right... =)

--
$you = new YOU;
honk() if $you->love(perl)