Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Monday October 25, 2004
12:38 AM

Devel::TestEmbed and S5

I got a request last week to do a lunchtime seminar of Monday on something different related to testing. After a bit of thought, I came up with Devel::TestEmbed, which embeds Test::More into the debugger so you can dynamically built test suites while debugging.

That's not so cool by itself, but it also creates a new tdump command that lets you dump out the tests you ran during the debugger session as a proper Test::More test, with the proper plan. It was almost as interesting developing the tests for the new command as it was implementing it.

The topper is that this is all done without actually changing any of the debugger's code at all!

I used the Eric Meyer's new CSS and Javascript-based presentation software, S5. It's way cool. You can get beautiful presentations with everything under really precise control. I've tweaked the existing S5 themes so that they look good on a 12" iBook and they're more useful for someone who wants to do a code-heavy presentation. As soon as I have a little extra time, I'm going to write a pod2s5 converter; S5 makes most presentation tools look silly.

Tuesday October 19, 2004
11:31 AM


I've started playing around with ChucK, a new language for music composition and performance.

ChucK has a lot of the things I've always wanted in a music language: it does not require you to link up little boxes to write programs; it does not require you to effectively program in a horrible assembly language because that was good enough in 1968; it does not require you to jump though hoops to figure out how to get multiple intependent processes working.

It primarily uses a single operator, => (known as "chuck"), which does all of the heavy lifting re datatype conversions, etc.
Here's an example. Let's say you were going to pass a white noise source through an ADSR (attack-decay-sustain-release), filter it, and then output it through a digital-to-audio converter, all under MIDI control.

In C-like, code this would look something like

/* Advance the time */
dacOut.tick(biQuad.tick(adsr.tick() * noise.tick()));
if( timeCount % 44 == 0 ) {
   /* Time to look for a MIDI message */
    if( midi.nextMessage() == __SK_NoteOn_ ) {
        /* Byte 3 non-zero: note-on, zero: note off */
        (midi.getByteThree() ? adsr.noteOn() : adsr.noteOff());
        /* Set the filter from the velocity */
        biQuad.setFreq( MD2Freq(midi.getByteTwo()) );

In csound, you'd decide it wasn't worth the trouble. In ChucK, this is simply

noise3 => ADSR => biquad1 => dac;
midi => (ADSR, biquad1);

No messing with what byte does what in the MIDI message, no having to run the idle timing loop. It just works. The ChucK operator takes care of all the conversion and the individual units use whatever they can.

In the spirit of reasonable languages (like Perl), ChucK lets you decide waht you want to deal with. Durations and time are native datatypes: units run from samp (the length of a single sample, or 1/44K second) to week. Artihmetic is supported:

3:second + 100:ms => dur quarter;

This defines the duration of a quarter-note as 3.1 seconds. Time is dealt with by chucking a new duration into now; you can also (as shown above) allow external events, like incoming MIDI messages, to advance time for you.

These two aspects, dealing with time and setting up flows of data, are the things that are most problematic for me in trying to use so-called "music languages".

ChucK also has a built-in concurrency model called shreds which is possibly of interest to other programming languages. Shreds are unlike threads in that threads are not deterministic and have no timing guarantees; shreds are guaranteed to be deterministic and allow synchronization down to the sample.

Shreds work because the advancement of time happens when the program says time advances. This means that the ChucK core can always know when a shred is supposed to do whatever it is planning on doing and schedule it deterministically.

As if this wasn't all cool enough, the Chuck core can add and delete shreds dynamically; so you can do something like this:

bash $ sudo nice -20 chuck --loop
bash $ chuck +
[chuck](VM): sporking incoming shred: 1 (
bash $ chuck +
[chuck](VM): sporking incoming shred: 2 (
... (add a pile more shreds)
bash $ chuck - 1
[chuck](VM): removing shred: 1 (
bash $

You can start and kill shreds at will; If they're all advancing time at the same rate, the beat lines up and it sounds ... pretty cool. Chuck calls this "on-the-fly" programming; very similar to the Hacking Perl in Nightclubs folks. It might be very interesting to try writing some Perl code that emitted ChucK code instead of MIDI directly. Heck, it sould even system the shreds randomly, letting the shreduler handle the synchronization.

Anyway, it's way cool. I have a little free-running ChucK program which simulates a Fender Rhodes noodling away in the background as I type this; it even runs nicely on my Powerbook G4 with a fair bit of other stuff going on.

Friday September 24, 2004
11:36 AM

GraphViz::Data::Structure 0.10 - hacks away!

I've released yet another version of GraphViz::Data::Structure today.

This one looks for the problem that GraphViz 2.0 has and substitutes its own patched version of the code in question if the test fails.

Obviously, I'm going to need to check out Leon's new record support (which I already think has a similar bug) and write some tests to complete the patch I sent him.

Wednesday September 22, 2004
09:25 AM


Two new versions in two days. Thanks to Devel::Cover pointing out where I hadn't tested adequately, I was able to find a number of bugs that my first set of tests missed.

The new version seems to work fine on OS X and on Linux, but there were some odd errors on Solaris. Anyone have a Solaris machine they'd be willing to try it out on and see if they can point out the bug?

Update: It's a bug in the 2.0 version of GraphViz itself; I'm still running with version 1.8, which doesn't have the bug. Patch appended for your dining and dancing pleasure:

--- /usr/local/lib/perl5/site_perl/5.8.3/    Wed Sep 22 15:56:22 2004
+++ Wed Sep 22 15:55:46 2004
@@ -408,7 +408,7 @@
       $node->{label} = $node->{name};
   } else {
-    $node->{label} =~ s#([|<>\[\]{}"])#\\$1#g;
+   $node->{label} =~ s#([|<>\[\]{}"])#\\$1#g unless $node->{shape} eq 'record';

   delete $node->{cluster}

The patch turns off the newly-added escaping of characters that dot treats as special. Since record shapes need these special characters, escapling them gives you nice oval nodes with names like <port1>1|<port2>2, and of course edges that are supposed to hook to those ports can't find them.

Thursday August 19, 2004
01:14 PM

Brain. Hurts.


Just when you thought it couldn't get any worse than Visual BASIC...

Saturday July 24, 2004
11:40 PM

iFire+Pro Speakers = cheap stereo bliss

I really like the Apple Pro Speakers. For a pair of small, portable speakers they're hard to beat in terms of clear, clean reproduction. And they're cheap. You can find a demo set for $29! Okay, the bass response is so-so, but they beat the heck out of most 2.0 speakers, and they really are cheap. For me, they beat the Bose Mediamates in a head-to-head comparison, and the Boses cost $100.

"But, Joe," you say. "I don't have a flat screen iMac or a G4 or G5 tower with the funny plug and built-in amp to drive these. I can't use these speakers." Enter the Griffin iFire. This little beastie incorporates the small (10-watt) amp needed to drive the Apple Pro Speakers. it just needs Firewire power. So you can hook it up to any Firewire-equipped Mac or PC: plug the iFire into the headphone jack, and the Apple Pro speakers in to the iFire and voila - you're golden.

"But, Joe," you say."I don't even have a Firewire port." Okay, then get yourself an iPod power supply ($45). Add the portable music source of your choice, and you've got an impressive little setup that takes up very little space. I'm currently using one set of speakers plus the iFire and iPod charger with my old portable CD player to provide a nice little system in the room where we do yoga.

We'll probably pick up another one of these for the other room because they really are a good deal for the price. And before all the audiophiles pronounce me tin-eared, we use the Creative Labs I-Trigue 3300s for the primary system when we really want to listen to the music.

Tuesday April 06, 2004
11:15 AM

"What's Wrong With Perl"

I read this and started to write a pissed-off journal article about it. Then I thought for a bit and realized that it doesn't matter.

I don't need to fight for Perl. I need to write it. Python isn't better. Perl isn't better. Perl is better for me personally because I can think in it. I can do things in it that can't easily be done in Python - as far as I know.

I have a job to do. It's writing code. It isn't to crab at people who don't like Perl. They can waste their energy on saying it sucks. They're not writing code while doing that.

Who is spending time better?

Monday March 15, 2004
01:53 PM


I attended the Sting concert Thursday night. Third row seat, in a small theater. Maybe ten feet to the band.

God in Heaven, what a concert. If you've got a chance to see him this tour, do it.

The first half hour was a solid, heartfelt performance, but then the energy suddenly swung up and up and UP... Two hours later, and two encores it was over; possibly the most intense musical experience I've ever witnessed. The band was on fire.

And, to bring it back to computers, I noticed the 17" Powerbook that was a prominent part of the setup - not only the select tool of alpha geeks, but of alpha musicians...

Wednesday February 18, 2004
09:18 AM

Not enough Jerkcity? Write your own


Wednesday August 27, 2003
11:10 AM

"I think it should be bright orange."

Today's Goats reminded me so of the infamous orange auction.