perlmeditation
eyepopslikeamosquito
<P>
In the late 1980s, Portland Oregon's third most famous resident
(after Monica Lewinsky and Tonya Harding) was not poring over
crusty clothing stains or thumping knees with an iron bar.
He was far too busy signing his many usenet posts with:
<blockquote>
Just another C hacker,<br>
Just another Unix hacker,<br>
</blockquote>
and so on.
Perl was new then.
And our intrepid usenet hacker loved Perl so much that he
insisted on answering requests for Unix shell/sed/awk help
with snippets of <I>Perl</I> code.
So much so that many posters resorted to inserting "No Perl please"
in their posts! Of course, making such a request on usenet is futile
and
<a href="http://use.perl.org/comments.pl?sid=10975&cid=16619">the barrage of Perl snippet responses</a>
continued unabated.
Indeed, so much did our maverick enjoy this little game, that he formed part of
<a href="https://groups.google.com/groups?selm=1989Dec7.214625.8627%40mcmi.uucp">the 2.7% who voted against</a>
the formation of a separate comp.lang.perl newsgroup in 1989.
</P>
<P>
Having got used to signing "Just another ____ hacker,"
it just seemed normal and natural to continue the tradition by
signing his Perl missives with:
<blockquote>
Just another Perl hacker,
</blockquote>
Little did he realize that he was adding a new word
to the computing lexicon: the
<a href="http://en.wikipedia.org/wiki/Just_another_Perl_hacker">JAPH</a>.
</P>
<P>
Ironically, in later years, he expressed
some regret
about his creation because JAPHs seemed at least partly responsible
for an over-emphasis on Perl obfuscation and trickiness --
which did not portray Perl as he would have liked
(see [id://173857]).
</P>
<P>
This, the second installment in the Perl Culture series,
focuses on [merlyn]'s little gift to Perl culture: the JAPH.
</P>
<readmore>
<P><B>What is a JAPH?</B></P>
<P>
A JAPH is simply a program that prints "Just another Perl hacker,"
to stdout. The basic idea is to use this (arbitrary) program
specification to highlight interesting language features in
the spirit of
TMTOWTDI.
In deference to its usenet signature origins, JAPHs are usually
limited to at most 4 lines, with each line at most
80 characters in length. To delight (and not bore) the reader,
a JAPH is expected to employ obscure or surprising or amusing syntax.
</P>
<P>
Of course, the idea of using an arbitrary canonical program
to learn and demonstrate a language is hardly new.
See, for example:
<a href="http://www2.latech.edu/~acm/HelloWorld.shtml">hello world</a>,
<a href="http://www.99-bottles-of-beer.net/">99 Bottles of Beer</a>, [id://602901|FizzBuzz],
<a href="http://www.nyx.net/~gthompso/quine.htm">quines</a>, and
<a href="http://paris.mongueurs.net/aplusplus.html">the delightful Perl Mongueurs $A++ obfu page</a>.
The JAPH, however, is special to Perl lovers because of its
long traditions and its uniqueness to Perl.
</P>
<P><B>What was the first JAPH?</B></P>
<P>
As described
<a href="http://www.mail-archive.com/fwp@perl.org/msg00235.html">here</a>,
the first JAPH was written by Randal L. Schwartz in 1988 and was simply:
<CODE>
print "Just another Perl hacker,"
</CODE>
Note the capitalization and trailing comma; they will be put
under the microscope in a later section.
</P>
<P>
According to the <a href="http://www.cpan.org/misc/japh">CPAN JAPH Archive</a>,
the first (mildly) obfuscated JAPH was:
<CODE>
From merlyn@iwarp.intel.com (Randal Schwartz) 1 Feb 90 22:28:58 GMT
@a=split(/(\d)/,"4Hacker,2another3Perl1Just");shift(@a);%a=@a;print "@a{1..4}";
</CODE>
Actually, I notice that this CPAN "JAPH" archive
contains many entries that are obfus, <I>not</I> JAPHs!
</P>
<P><B>Did Larry ever write a JAPH?</B></P>
<P>
According to
<a href="http://history.perl.org/PerlTimeline.html">history.perl.org</a>
he wrote two!
</P>
<P>
The first picked a random merlyn post from his news spool,
ran the code, but printed "Not " in front of it.
I can't find the actual code that did this, however.
</P>
<P>
Interestingly, the second, created in March 1990, also formed the
first Perl poem ever written:
<CODE>
print STDOUT q
Just another Perl Hacker,
unless $spring
</CODE>
Reading this historic poem aloud, with <CODE>STDOUT</CODE> pronounced <I>standard out</I> and <CODE>$</CODE> pronounced <I>dollar</I>, indicates that it's a haiku, containing the trademark 5-7-5 syllables in its three lines. Notice that this Perl 3 code no longer runs with modern perls.
</P>
<P>
If you know of any other JAPHs penned by Larry, please let us know.
</P>
<P><B>Some Classic JAPHs</B></P>
<P>
Choosing a favourite JAPH depends on personal preference:
some folks like JAPHs that break B::Deparse and are almost
impossible to decipher; others prefer ones that simply make them laugh.
Of the JAPHs I've seen,
the one that made me laugh the most is this one:
<CODE>
$Old_MacDonald = q#print #; $had_a_farm = (q-q:Just another Perl hacker,:-);
s/^/q[Sing it, boys and girls...],$Old_MacDonald.$had_a_farm/eieio;
</CODE>
taken from
<a href="http://www.stonehenge.com/merlyn/UnixReview/col20.html">this June 1998 Unix Review magazine article</a> by [merlyn].
</P>
<P>
After [merlyn], Abigail is perhaps the most celebrated and prolific JAPH author. Here are a few from his
<a href="http://www.cpan.org/misc/japh">collected works</a>:
<CODE>
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
</CODE>
</P>
<P>
<CODE>
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
</CODE>
</P>
<P>
<CODE>
$; # A lone dollar?
=$"; # Pod?
$; # The return of the lone dollar?
{Just=>another=>Perl=>Hacker=>} # Bare block?
=$/; # More pod?
print%; # No right operand for %?
</CODE>
</P>
<P><B>The Battle of the JAPH Standards</B></P>
<P>
Lacking an ANSI JAPH standard, the past decade has seen a
gripping power struggle for control of the de facto JAPH standard
between their inventor, [merlyn], and perhaps their greatest
<a href="http://ucan.foad.org/~abigail/Perl/Talks/Japhs/">promoter</a>,
the inimitable Abigail.
</P>
<P>On one
<a href="http://www.mail-archive.com/fwp@perl.org/msg00244.html">occasion</a>,
upstart Abi claimed the right to change the JAPH standard:
<CODE>
Being the one who has given several talks about Japhs, I've decreed
that a Japh uses the following rules:
- It prints "Just another Perl Hacker" with some reasonable
capitalization, followed by optional punctuation (comma,
dot) followed by an optional newline. Some flexibility
in rules makes for more Japhs. Printing to either STDOUT
or STDERR is allowed.
- It doesn't print anything else.
- The program uses at most 4 lines, each line at most 80 characters.
- It uses obscure or surprising syntax.
</CODE>
</P>
<P>As you might expect, merlyn
<a href="http://www.mail-archive.com/fwp@perl.org/msg00246.html">firmly rebuffed</a>
this claim, and has tenaciously defended his original
JAPH standard on many other occasions. See, for example:
[id://32566],
[id://394533], and
<a href="http://www.mail-archive.com/fwp@perl.org/msg00241.html">here</a>.
</P>
<P><B>How is a JAPH distinct from an obfu?</B></P>
<P>
As argued by [BooK] in [id://57400], there are significant differences
in emphasis between JAPHs and obfus. I don't want to enter this debate
right now, but might in the next installment, which will focus on obfus.
</P>
<P><B>References</B></P>
<P>
<ul>
<li> <a href="http://en.wikipedia.org/wiki/Just_another_Perl_hacker">Wikipedia JAPH entry</a>
<li> <a href="http://www-128.ibm.com/developerworks/linux/library/l-japh.html">Cultured Perl: the elegance of JAPH</a>
<li> <a href="http://www.cpan.org/misc/japh">CPAN JAPH Archive</a>
<li> [id://413324]
</ul>
</P>
<P><B>Other Articles in This Series</B></P>
<P>
<ul>
<li> [id://410774]
<li> [id://424355]
<li> [id://437032]
<li> [id://451207]
<li> [id://540609]
</ul>
</P>
<P>
</P>
<P>
<small>
Updated April 2006: Added some Abigail JAPH examples.
</small>
</P>
</readmore>