Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The language designer said to the programmer: “Thank you for freeing me from my prejudices. I understand now that a language must not try to force the programmers to follow any single paradigm, but should instead offer all the features the programmer may want to use. As a reward, you may wish for any three features and I will add them to the language.”

The programmer replied: “I'd like a powerful domain-specific language for blowing up binary strings to small parts.”

The language designer granted the programmer's wish, and the programmer promptly tried it, saying

#!perl use warnings; use strict; use 5.010; use Time::HiRes "sleep"; our $DELAY = 0.05; # determine size of terminal my $w = pack "S4", 24, 79; ioctl STDIN, $_, $w for 0x40087468, 0x5413; our($R, $C) = unpack "S2", $w; $R--; our $b; if (rand 3 < 1) { # glider gun pattern $b = pack "(A$C)[Lx$R]", ("")x3, split /^/, " 1 1 1 11 11 11 1 1 11 11 11 1 1 11 11 1 1 11 1 1 1 1 1 1 1 11 "; } else { # generate random bitmap as starting state $b = pack "(A)*", map { rand 3 < 1 } 0 .. 2*$R*$C; } system qw"tput clear"; while () { # display game board system qw"tput home"; say for unpack "xx$C(a$C)$R", $b; sleep $DELAY; # game of life evolution step no warnings "numeric"; $b = pack "xx$C(A)*xx$C", unpack "(x7a/(x13)X4Ax!18)[(A$R)$C]", pack "((a*)17xx!18)*x3", unpack "((AAAX3AAA\@$C AXAAAXAx$C (X3AAA)2\@)$C)$R", $b; } __END__

The programmer watched the pretty patterns appearing in his terminal.

After a while, the language designer asked “And your other wishes?”

The programmer's reply was “Why would I need other wishes?”


  1. The story is stolen from xkcd strip 152: Hamster Ball, reinterpreted slightly.
  2. In case you can't guess from the comments, this obfuscation shows the evolution of Conway's Game of Life cellular automaton, starting from either a completely random pattern or a fixed glider gun pattern. The program runs forever, stop it with control-C if you get bored, then restart to get another random pattern or the glider gun.
  3. It may be worth to resize your terminal to larger so that you get a larger game board.
  4. The glider gun also serves as an example to show how to edit the program to start from a pattern of your choice.
  5. It is possible that the dialog is internal, the language designer and the programmer being just different aspects of the same person.
  6. The programmer has used the word “explode”, but the language designer took liberty to name the feature “unpack” instead to avert curious incidents in case programmers obliviously discuss the feature in an airport waiting room. He was thus wiser than the designers of Standard ML, as that language has a function named explode to blow a string to pieces.
  7. I have already known from my previous obfuscations that the power of unpack is easy to abuse: unpack can follow a linked list, generate the list of suffixes of a string, aid in arithmetic over a finite field, or (Update) drive a quine.
  8. The evolution step on the whole board is implemented as just two calls to unpack and two calls to pack. Is it possible to use even fewer calls?

In reply to Game of life ran by unpack function by ambrus

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (4)
    As of 2018-06-19 22:35 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (115 votes). Check out past polls.