The Most Powerful Programming Paradigm in the World?

Cornell Facebook Camp Hackathon
Photo by Benjamin Golub

I’m not a hackathon kinda guy. I don’t get off on solving hard or novel problems. I don’t believe in contests. I’m not particularly energized by the idea that a whole bunch of us are trying to solve the same problem at once— I do believe in community, and I appreciate being able to interact with other developers, but on a different level than just getting into the same (virtual or physical) room together, eyes to the computer screen.

So why then did I participate in the Dallas/Fort Worth Perl Mongers
Winter 2013 Hackathon? Continue reading

Posted in Uncategorized | Tagged , , , , , | 2 Comments

Mopping up with Perl

30 Ways to Shock Yourself #2,
photo by Bre Pettis,
from the book Elektroschutz in 132 Bildern

I ported my Hackathon entry to the latest Perl dev release (5.19.9), the one with built-in sub signatures.

I had originally designed it using the latest p5-mop and Алексей Капранов’s (Alexei Kapranov’s) signatures package. (I thought this was more in the spirit of mop than Sub::Signatures.) And that worked fairly well, with only a few glitches, and only a few complaints. But since sub signatures are now available (Yay!) in core (No hiding how I feel about that, eh?), it seemed a good time to bring the experiment fully into the present.

And here are some discoveries from my experiences with Perl mop+signatures. Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

What I’m Doing on

Dragon Quest VIII-Jeremy G

I’ve begun listing certain public SD mini-projects as quests on my page at

These include a few items that fell out of my recent “Benchmarking Perl 6” talk:

  • Produce and release a video of the talk
  • Suggest Pull Requests for perl6-bench
  • Port the Richards benchmark to Perl

But I will be adding to this list any items that may be of interest to the broader SD community, and especially the Perl community. Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Benchmarking Perl 6: How Ready for Prime Time Is It?

Racing at the 2009 Camel Cup in Alice Springs, Australia
Photo © 2009 Toby Hudson CC BY-SA

Here are the slides from the talk I gave at this month’s Boston Perl Mongers meeting, this past Tuesday: Benchmarking Perl 6: How Ready for Prime Time Is It?

The talk examines:

  • Perl 6’s suitability for “production.” (Your definition may vary.)
  • Experiences of the state and stability of Rakudo.
  • Benchmarks of my favorite P6 features.
  • Lines of P6 code from everyday life.
  • Some comparisons of P6 with P5.


P.S. There’s a lot of the story that you miss when you can’t hear the talk. I may be able to post an audio recording and/or a YouTube video with the audio combined with some version of the slides: still looking into these. Unfortunately, I didn’t have time to set up a proper screencast during the talk, so I’m putting together these productions after the fact. And I’m sure there’s a lesson somewhere in there on the efficiency of good planning in design. 🙂

P.P.S. I collected my data using Geoff Broadwell’s (japhb) per6-bench benchmarking framework. (You can catch the code I used in my GitHub fork of perl6-bench.) I also highly recommend his YAPC::NA 2013 talk.

Posted in Uncategorized | Tagged , , , , | Leave a comment

More Simple Stats with Perl 6

Last time, a time long, long ago, in a universe far, far away, I left you with the following Perl 6 code (or something like it). This code reads in a series of book heights and displays the number of books of each height (in order from shortest to tallest).

my %num_of_height;
for lines() {
    if m/^ \s* (\d+[\.\d+]?) [\s* x \s* (\d+)]? \s* $/ {
        my $height = +$0;
        my $num = +($1 || 1);
        %num_of_height{$height} += $num;
    } elsif ! m/^\s*$/ {
        note "Invalid line ignored: $_";

#| unique book heights seen, in order from shortest to tallest
my @heights = sort { $^a <=> $^b }, keys %num_of_height;

say "Histogram data:";
for @heights -> $height {
    my $num = %num_of_height{$height};
    say "$height x $num";

As you may recall, this little bit of somewhat less-than-useful P6 script was inspired by a homework assignment in my daughter’s high-school statistics course. While she manually counted up the heights of the books we measured, in order to draw a histogram of the data, I wrote a Perl script to do the same counting.

Since then, for kicks, I’ve also hacked together about 50 lines of code to display an actual histogram of these data, with horizontal bars of *****. I’m not going to go into that code here, because I did not write it at the time, but if you want, you can check it out on Github.

However, I did discover how succinctly Perl 6 could answer the other questions from the assignment. Continue reading

Posted in Uncategorized | Tagged , , | 4 Comments

Reason #2 Why We Write Unit Tests

Seen on DamnLOL

Ninety-nine little bugs in the code,
Ninety-nine little bugs!
You take one down, patch it around,
A hundred and seventeen bugs in the code!

(See also Twelve Benefits of Writing Unit Tests First.)

Posted in Uncategorized | Tagged , , , | Leave a comment

Some Simple Stats with Perl 6

When my daughter told me she was taking statistics, I wondered how she could do that without knowing any calculus. Then on second thought, I guess there is a certain amount you can do with statistics, even without knowing any calculus.

Ah, yes. And last night’s homework assignment drilled that home. She asked me to help her. First, she needed to find a quantitative data set she could use to construct a histogram. Looking around the living room, I suggested, “What about the heights of the books on my book shelves? You could measure the spines and write them down in a data table.”

Now, I currently have nine full shelves of books in my living room, everything from Dave Barry and Dilbert to Peopleware to marketing and memoirs, theology and psychology, short stories and the theory of writing, to Holly Lisle, Douglas Adams, Robert Heinlein, and The Sisterhood of the Traveling Pants. (And I am not making this up.) And those are just the books that are actually on shelves, not the books that are still in boxes.

I think she was a little overwhelmed by the idea.

“You don’t have to include all the books, just one or two shelves worth. Maybe that one over there, half full of mass-market paperbacks all the same size.” Easy to measure, easy to count.

So we chose that shelf and the shelf just under it, a nice cross-section of fiction in mass-market, trade paperback, and hardcover. And then while she was manually collating the data, inspiration struck me. Why don’t I write a quick Perl 6 script to check her results. It’ll give me something to write about; plus I’ll see whether Perl 6 is really useful for anything, especially minor scripts.

And as it turns out, it might be. Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

How Fast (or Slow) Is Perl 6?

Racing at the 2009 Camel Cup in Alice Springs, Australia
Photo © 2009 Toby Hudson CC BY-SA

In my previous post, I created a short, simple, sweet, and très élégant Perl 6 function to find all the primes up to a given maximum.

Unfortunately, Rakudo spent over 11 seconds to find the 168 primes up to 1000.

Now, granted, this algorithm is exceedingly naïve. It divides every candidate integer by every prime that came before it, resulting in some 91,873 trial divisions (and another 91,873 boolean tests). Even so, that boils down to some 280,000 CPU clock cycles per inner loop (on my old 2.33 GHz Intel Core 2 Duo, with one core tied behind its back).

As a comparison, an implementation of the same algorithm in Perl 5 took only 44 milliseconds to find the same 168 primes using the same number of loops, or about 1100 CPU clock cycles per loop. Still not blazing fast, but more like what I would expect from an interpreted language… Of course I have Rakudo running on the JVM, and I’m benchmarking it after the JIT compiler has squeezed every last little bit of performance it can out of the code it’s given. A native-Java implementation ran even faster— but I’m getting ahead of myself. Continue reading

Posted in Uncategorized | Tagged , , , | 6 Comments

Perl 6 and the Price of Elegant Code

The project that first made me fall in love with Perl…

Perl 5 had recently launched, with new features for object-oriented programming, includable modules, lexically scoped variables, and references—including closures. At the time, I was writing boot code, diagnostics, and production test software for Kurzweil-brand electronic musical gear. Part of the challenge of doing embedded systems back then was getting the machine code into the actual machine. The C compiler, assembler, and linker generated a binary file, which needed to be physically programmed into multiple EPROM chips in order to run the code on our custom hardware. We actually had software tools to pad out, checksum, and split up the binary data so it could programmed into multiple EPROMs according to our specifications.

And then we started designing systems that exceeded the capabilities of our tools. And I had to hack together custom C programs to reformat the binary data according to the new requirements. I think I might have done that twice. And then I asked myself whether Perl, which was always very good with strings of data—and what is a binary file but a big string of data? I asked myself whether Perl might be able to do a better job. Continue reading

Posted in Uncategorized | Tagged , , , , | 3 Comments

Perl 6’s Top 3 Coolest Features

Perl 6 has some really cool features. Features I’d like to use in production projects. But is Perl 6 suitable for production?

I keep hearing, no, because it’s unstable, the spec is still being hammered out, there are still too many bugs, it’s still too slow, the documentation lacks (or is just plain wrong), key features are still missing, it has insufficient module support.

But I have never been one who blindly accepts the evaluations of the crowd, because the crowd is often dominated by zealots twisted by hate and zealots twisted by love, and I’ve found a great beauty and symmetry in that nuance that lies in between zealotries.

Besides which, Perl 6 (hereinafter referred to as “P6”) includes a number of features that fit a particular real-world application that I happen to be thinking about. That’s another post. But several P6 features struck me. Here are the top three: Continue reading

Posted in Uncategorized | Tagged | 2 Comments