"David Golden" <[EMAIL PROTECTED]> wrote on 02/23/2008 03:00:19 PM:

> Well, it was written to be clever, not maintainable. :-)

Point taken.  I did mention that I was probably going to far in what was
just a game. :-)

> In response to Conway: clever algorithms are good; clever code is not so
good.

(sidebar: I used to teach this stuff.  I had one student that used the
names of dead russian authors for ALL variables.  Finally learned the joys
of sed and perltidy.)

Clever algortithms, depending on how you mean that, is the whole game,
except for those grunts who only make a money off coding.  What makes
coding a human art instead of a mechanical subject is creative play with
ideas -- that whole data structures + algorithms thing.

>   my $regex = join q{}, map { $num2chars[$_] } @digits;
>
> That seems pretty straightforward code to me, rather than clever code.

I don't think I disagree; but then I remember one class I took as a grad
student: we have a visiting prof, and he was putting a proof up on the
board.  Threw up an introductory lemma, and announced "the proof is clear."
The hosting professor took issue: a lively 30 minute discussion followed,
where it was decided that indeed, the proof was obvious.

obsSyntaxPoint -- its straightforward, but in the code you wrote above, you
forgot the [] -- so the regex will miss the grouping.. unless I"m missing
something.  What you had in your earlier post was
my $regex = join q{}, map { "[$num2chars[$_]]" } split //, <STDIN>, 7;
^                                     ^
And yes, once you *think* about it, its elegant.  Its clever.   You have
natively translated the algorithmic idea into perl code.  You've made it at
least reasonably straightforward by using explicit  join -- map -- splits
instead of using obscure scalar vs. list properties.  (Although, why not qr
it?)  And I like it much better than using a tr// which you have to put
inside an eval.  Which makes it a good solution for a game.

>  It's great that you're enjoying Perl Best Practices, but many of those
> recommendations do require some healthy skepticism and Damian's
> introduction (I think) makes the point that they are just one opinion

Very true.  I read an interview where they asked him about the differences
between his 2^8 and Wall's 5*8, and his comment was that both held up.
What I find is that while there are a couple of things that I disagree with
(e.g. the use of postfix selectors) I think the point is that you have to
have *something*.  [I usually start with Weinburg's Ten Commandments, but
that isn't coding specific.] Conway's are well thought out, reasonably
consensual, and based on more experience than I (and probably thee).  But
consider the audience for the game -- it strikes me that these are more
likely to be someone either new to perl or relatively new to programming.
These are the kinds of problems that you ask of students half way through a
semester.  And they would do very well indeed to learn style from PBP.

--woody

--
                                                                       
 Dr. Robert "Woody" Weaver    Security, Privacy, Wireless, and IT      
                              Governance                               
                                                                       
 IT Security Architect        Phone: 240-782-4260                      
                                                                       


--
There are still some other things to do, so don't think if I didn't fix
your favorite bug that your bug report is in the bit bucket. (It may be,
but don't think it. :-) Larry Wall in <[EMAIL PROTECTED]>
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to