Unobfuscated Perl Code Contest

Fake News written by James Baughn on Saturday, September 16, 2000

from the can-anyone-say-job-security? dept.

The Perl Gazette has announced the winners in the First Annual Unobfuscated Perl Code Contest. First place went to Edwin Fuller, who submitted this unobfuscated program:

 #!/usr/bin/perl print "Hello world!

";

"This was definitely a challenging contest," said an ecstatic Edwin Fuller. "I've never written a Perl program before that didn't have hundreds of qw( $ @ % & * | ? / ! # ~ ) symbols. I really had to summon all of my programming skills to produce an unobfuscated program."

The judges in the contest learned that many programmers don't understand the meaning of 'unobfuscated perl'. For instance, one participant sent in this 'Hello world!' program:

 #!/usr/bin/perl $x='unob'; open OUT, ">$x.c"; print OUT <<HERE_DOC; #include <stdio.h> int main(void) {  FILE *f=fopen("$x.sh", "w");  fprintf(f,"echo Hello world!\n");  fclose(f);  system("chmod +x $x.sh");  system("./$x.sh"); return 0;  } HERE_DOC close OUT; system("gcc $x.c -o $x && ./$x"); 

"As an experienced Perl monger," said one of the judges, "I can instantly tell that this program spits out C source code that spits out a shell script to print 'Hello world!'. But this code certainly does not qualify as unobfuscated Perl -- I mean, most of it isn't even written in Perl!"

He added, "Out of all of the entries, only two were actually unobfuscated perl. Everything else looked like line noise -- or worse."

The second place winner, Mrs. Sea Pearl, submitted the following code:

 #!/usr/bin/perl use strict; # Do nothing, successfully exit(0); 

"I think everybody missed the entire point of this contest," ranted one judge. "Participants were supposed to produce code that could actually be understood by somebody other than a ten-year Perl veteran. Instead, we get an implementation of a Java Virtual Machine. And a version of the Linux kernel ported to Win32 Perl. Sheesh!"

In response to the news, a rogue group of Perl hackers have presented a plan to add a "use really_goddamn_strict" pragma to the language that would enforce readability and unobfuscation. With this pragma in force, the Perl compiler might say:

  • Warning: Program contains zero comments. You've probably never seen or used one before; they begin with a # symbol. Please start using them or else a representative from the nearest Perl Mongers group will come to your house and beat you over the head with a cluestick.
  • Warning: Program uses a cute trick at line 125 that might make sense in C. But this isn't C!
  • Warning: Code at line 412 indicates that programmer is an idiot. Please correct error between chair and monitor.
  • Warning: While There's More Than One Way To Do It, your method at line 523 is particularly stupid. Please try again.
  • Warning: Write-only code detected between lines 612 and 734. While this code is perfectly legal, you won't have any clue what it does in two weeks. I recommend you start over.
  • Warning: Code at line 1,024 is indistinguishable from line noise or the output of /dev/random
  • Warning: Have you ever properly indented a piece of code in your entire life? Evidently not.
  • Warning: I think you can come up with a more descriptive variable name than "foo" at line 1,523.
  • Warning: Programmer attempting to re-invent the wheel at line 2,231. There's a function that does the exact same thing on CPAN -- and it actually works.
  • Warning: Perl tries to make the easy jobs easy without making the hard jobs impossible -- but your code at line 5,123 is trying to make an easy job impossible.
  • Error: Programmer failed to include required string "All hail Larry Wall" within program. Execution aborted due to compilation errors.

Of course, convincing programmers to actually use that pragma is another matter. "If somebody actually wanted to write readable code, why would they use Perl? Let 'em use Python!" exclaimed one Usenet regular. "So this pragma is a waste of electrons, just like use strict and the -w command line parameter."

Rate this story

No votes cast

Share