Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

The Lighter Side of Perl Culture (Part II): JAPH

by eyepopslikeamosquito (Archbishop)
on Dec 05, 2004 at 06:34 UTC ( [id://412464]=perlmeditation: print w/replies, xml ) Need Help??

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:

Just another C hacker,
Just another Unix hacker,
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 Perl 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 the barrage of Perl snippet responses continued unabated. Indeed, so much did our maverick enjoy this little game, that he formed part of the 2.7% who voted against the formation of a separate comp.lang.perl newsgroup in 1989.

Having got used to signing "Just another ____ hacker," it just seemed normal and natural to continue the tradition by signing his Perl missives with:

Just another Perl hacker,
Little did he realize that he was adding a new word to the computing lexicon: the JAPH.

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 •Re: Obfuscation has no place in production code).

This, the second installment in the Perl Culture series, focuses on merlyn's little gift to Perl culture: the JAPH.

What is a JAPH?

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.

Of course, the idea of using an arbitrary canonical program to learn and demonstrate a language is hardly new. See, for example: hello world, 99 Bottles of Beer, FizzBuzz, quines, and the delightful Perl Mongueurs $A++ obfu page. The JAPH, however, is special to Perl lovers because of its long traditions and its uniqueness to Perl.

What was the first JAPH?

As described here, the first JAPH was written by Randal L. Schwartz in 1988 and was simply:

print "Just another Perl hacker,"
Note the capitalization and trailing comma; they will be put under the microscope in a later section.

According to the CPAN JAPH Archive, the first (mildly) obfuscated JAPH was:

From (Randal Schwartz) 1 Feb 90 22:28:58 GMT @a=split(/(\d)/,"4Hacker,2another3Perl1Just");shift(@a);%a=@a;print "@ +a{1..4}";
Actually, I notice that this CPAN "JAPH" archive contains many entries that are obfus, not JAPHs!

Did Larry ever write a JAPH?

According to he wrote two!

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.

Interestingly, the second, created in March 1990, also formed the first Perl poem ever written:

print STDOUT q Just another Perl Hacker, unless $spring
Reading this historic poem aloud, with STDOUT pronounced standard out and $ pronounced dollar, 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.

If you know of any other JAPHs penned by Larry, please let us know.

Some Classic JAPHs

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:

$Old_MacDonald = q#print #; $had_a_farm = (q-q:Just another Perl hacke +r,:-); s/^/q[Sing it, boys and girls...],$Old_MacDonald.$had_a_farm/eieio;
taken from this June 1998 Unix Review magazine article by merlyn.

After merlyn, Abigail is perhaps the most celebrated and prolific JAPH author. Here are a few from his collected works:

perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / + / / % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % + %; BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n" +)}'

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";

$; # A lone dollar? =$"; # Pod? $; # The return of the lone dollar? {Just=>another=>Perl=>Hacker=>} # Bare block? =$/; # More pod? print%; # No right operand for %?

The Battle of the JAPH Standards

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 promoter, the inimitable Abigail.

On one occasion, upstart Abi claimed the right to change the JAPH standard:

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.

As you might expect, merlyn firmly rebuffed this claim, and has tenaciously defended his original JAPH standard on many other occasions. See, for example: RE: RE: JAPH, •Re: step-by-step JAPH, and here.

How is a JAPH distinct from an obfu?

As argued by BooK in Separated JAPH/Obfuscation sections, 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.


References Added Later

Other Articles in This Series

Updated April 2006: Added some Abigail JAPH examples. April 2024: Added more References.

Replies are listed 'Best First'.
Re: The Lighter Side of Perl Culture (Part II)
by apotheon (Deacon) on Dec 06, 2004 at 10:16 UTC

    Good overview, interesting links, and amusing tone. Overall, I like it. I feel inspired by this somehow. Alas, my inspirations are rarely canonically correct.

    Now I just need to decide whether to make it permanent.

    print substr("Just another Perl hacker", 0, -2);
    - apotheon
    CopyWrite Chad Perrin

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://412464]
Approved by davido
Front-paged by grinder
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-13 10:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found