My sites

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).  Click to continue »

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.)

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.  Click to continue »

If You Followed This Blog for My SD Posts…

…I’ve moved all my software-development posts over to my new software-development blog, where I’m currently in the midst of a series chronicling my evaluation of Perl 6.

At least since the mid 2000′s, when I wrote about software, I tried to keep it popular, non-techie, or at least about the culture rather than the coding. On my new SD blog, I am no longer afraid to use lots of code snippets. And I’ve taken to publishing sample code on GitHub.

Why the change? Am I going back to software development? Yes, I think so. I haven’t given up writing. But I’ve updated my resume. I’ve come to terms with the fact that not everything and everyone and everyplace in software is like this:

On the other hand, I’m trying to avoid getting caught in a workplace like this again. For a creative type like me, who depends so heavily on innovation, on constant improvement, on challenging the status quo for the better. Working with others who do not share that passion, it can be positively demoralizing.

 Click to continue »

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.  Click to continue »

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.

A day or two later…

…and I thought it was so incredibly cool that I could replace a whole file of cryptic C code with a paragraph like:  Click to continue »

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:  Click to continue »

This Site Is Such a Hack

Hacking in a suite at clarionPhoto © 2010 Johan Nilsson CC BY-NC 2.0

Hacking in a suite at clarion
Photo © 2010 Johan Nilsson CC BY-NC 2.0

I’ve been wanting to set up a software-development blog for some time. And for some time I’ve been wrestling with the pains of managing multiple WordPress blogs. Back in the day, when I had just my writing blog and a LiveJournal, it wasn’t such a big deal. Since then, I’ve retired the LiveJournal—sorry, LJ friends—and have set up a number of other WordPress sites, for different niches in which I write. In particular, I have a personal blog, a political blog (because I decided I should not pollute my personal blog with political posts), and now a software-development blog (which you are currently reading).

When I spun off the political blog, I got a taste of what it meant to migrate posts from one WordPress instance to another. And my experience with this SD blog was ten times worse, because there were 10 times as many posts involved.

The short version of the story: WordPress is broken, and it will always be broken.  Click to continue »

State-of-the-Art Computer Folklore (part 5)


Photo © 2011 Giuseppe Savo CC BY-NC-ND 2.0

This is part 5 in my series of how the Mac reminded me why I fell in love with software development, and why it still matters.

While reading Andy Hertzfeld’s anecdotes (and those of his colleagues) of designing the original Macintosh computer, I was inspired, inspired to take account of my own passions, the passions that these stories reminded me of. Today, I continue that list:

  • I love to create new patterns. I love solving problems through discovery, inventing that which has never existed before. (From part 1.)

  • I love applying principles in new ways. I love working with abstractions, and turning them into concrete expression. I love challenging the status quo, breaking through the limits of what everyone else says is “possible.” (From part 2.)  Click to continue »

Syndicate content