[Chicago-talk] Sharing my pain

Jonathan Rockway jon at jrock.us
Mon Oct 16 09:28:08 PDT 2006

Most code is bad without context.  It's even worse when "obfuscated" for
posting to a mailing list.

In my opinion, when a programmer calls code "bad", he really means "I
didn't understand it in 10 seconds, so it sucks."   I think that most
programmers expect that other people's code look exactly like theirs.
This is because they spend the most time looking at their own code
(since they're writing it), and form a mental image of "good code" that
coincidentally looks exactly like their own.

If you want to get a better perspective on things, I suggest downloading
your favorite CPAN modules and trying to add features (or fix bugs,
whatever).  You'll see things in the code you don't like.  You need to
get over the trivial things (variable names, spacing styles, s***
instead of s{}{}, etc.) and think about really improving the code.
Factoring out common parts into a single (easily-testable) unit,
documenting embedded magic (long regexes, algorithms copied from Knuth),
and so on.  I suggest looking at MJD's "Perl Repair Shop" -- he has the
right idea there.  Feel free to improve readability as you go along, but
realize that code isn't bad just because it says "print STDERR 'foo'"
instead of "print {*STDERR} 'foo'".

> The code example you including is a piece of crap since it doesn't 
> define what it does and it doesn't use descriptive variables. Could 
> have been written in any language -- including Python.

Like I said, it's not that bad.  I don't know what it does (because it
was obfuscated), but it's a small and digestible chunk.  That's the most
you can ask for, really.

package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;

More information about the Chicago-talk mailing list