Blog Posts

A tale of two languages

While I was at OSCON I found myself chatting with various non-perl and ex-perl folks and many of them had the same impression of Perl as a great language for hacking out short scripts to get stuff done, right now and possibly under severe time pressure. For these people, those scripts would very rapidly become unmaintainable. And it’s easy to see why they came to that conclusion. Perl was originally designed and implemented by a systems administrator as a tool to make his every day tasks easier so there are a bunch of shortcuts and defaults that do exactly that - make Larry’s life in 1987 easier.

How can I keep from Singing

  <iframe width="100%" height="400" scrolling="no" frameborder="no" src=""></iframe>

Rules of Engagement

If you’re interested in the repertoire project, here’s my current rules of engagement for recording for it: One Song One Mic One Take (by which I mean no comping or overdubs, not “only one attempt”) So far, everything has been recorded using FiRe, a dead simple field recording app on the iPhone/iPad and uploaded pretty much directly from the phone to SoundCloud, though I am thinking of switching to using my BandCamp account because, although the player may not be as pretty, the site is free.

Calling any Xkb gurus

Right, I’ve about had it up to here with the Xkb documentation, and with the layout of my shiny new Kinesis Advantage Keyboard. The cursor keys on the kinesis are horribly situated. What I’d like to do is hit a key (AltGr, say) and have it put the keyboard into a navigation mode, with the arrow keys mapped onto WASD and possibly HKJL and, ideally with Home/End, PgUp, PgDn in sensible places as well, then, once I’ve done, hit the mode switch key again and I can carry on programming.

The Perils of RFSI

If you saw me at YAPC::NA or you follow me on Twitter, you’ll know that I’ve been waylaid by Repetitive Strain Injury, so I’m going to be cutting back even more savagely on the blogging I do here. However, I do need to vent, so I’m starting to use my Audioboo (for short audio blog posts) and accounts. I’ve been inspired by Jon Boden’s wonderful A Folk Song A Day project to undertake my own repertoire challenge.

An evening of open source entertainment

Over on Twitter, Allison Randal said: Open source isn’t just a licensing/business strategy, it’s a better way of producing software and a better way of training developers. The driving principle of the academic model is to make students fail. The bell curve rules, if all students pass something is “wrong". The driving principle of open source is to help each developer reach their own greatest potential.

Supporting the good guys

Graeme (@mathie) Matthieson is one of the good guys. He’s also one of the people behind the Scottish Ruby Conference (née Scotland on Rails). I spent my own money to go to the first one they ran, and it was a great conference. To judge from the tweets around this year’s conference, they’re not slacking off at all. Even though I’m back to being a Perl programmer nowadays, I wish I’d been in Edinburgh last week.

Falling out of love with a language

So, Giles Bowkett asked me on facebook “Why Perl?". This is the long answer. I’m a Perl hacker. I have been for around 16 years now. Around 5 years ago, prompted by the Pragmatic Programmer and Adam Turoff, I started looking at Ruby, and Ruby on Rails and sort of fell into maintaining Typo. Why? I was getting hacked off with Perl. I was coming to the end of my tenure/tether as Perl 6 Summarizer: watching a language that I still want to use before I die taking forever to get done gets wearing after a while, especially when you’re spending 8 hours a week summarizing the activities of a development community that, in parts, was verging on the toxic (it’s way better now).

Class decomposition and a handy delegation pattern

There’s something satisfying about reaching the point when you can’t decompose an object any further and all your methods are tiny and do one thing - it’s especially gratifying when you learn something new in the process. Sadly, it doesn’t happen as often as I’d like, there’s usually annoying bits and pieces where you have to placate the language in some fashion that breaks the flow of what you’re writing.

Twice now

In Ruby, when you’re doing division on integers, things can get a little counter intuitive. For instance, 6/4 is obviously 1. At least, it is until you decide that you’d rather have numbers that behave a little more like ‘real’ numbers and you do require ‘mathn’, a module in the Ruby standard library (ie, it comes as part of ruby). Then you enter a whole new world of rational maths, where 6 / 4 returns 3/2.

Test::Class::Sugar 0.3, no, 0.4

tap tap… Is this thing on? So, I recently noticed that Test::Class 0.33 got released, which means that Test::Class::Sugar no longer needs to depend on a development release, and I also noticed that it was embarrassingly easy to throw Test::Class::Sugar into an infinite loop by forgetting which way the >> goes when you want to specify the number of subtests in a test method. So, I’ve done a quick fix of the infinite loop problem as well and uploaded version 0.

Perl: Not just a hobby any more

Back in January, I wrote that I was choosing Perl to revisit as my language for recreational programming. Quite a bit has happened since then. I gave a talk on MooseX::Declare to the London Perl Mongers and will be delivering an extended version at this year’s YAPC::Europe in August. Then, a week ago, I accepted an offer to work full time as a Perl programmer again. In London. Sing “Ho!” for the life of the long distance commuter. Presentation Video

Back in (crikey) February, I gave a talk at the London Perl Mongers’ technical meeting about Moose for Ruby Programmers and wrote it up here. Mike Whittaker was in the front row of the audience with his iPhone and, a couple of minutes in, started a voice recording and gave me a copy. So… finally… I’ve taken the time I should have been using to write another article for The H and wrestled the slides and the audio into something like sync and uploaded the results to Vimeo for your viewing pleasure.

Another conference season, another dumb sexist

Mum was often the only women [at British Leyland sales conferences]. In those days it was apparently common for presenters to slip the occasional naked lady into the slides “just to keep everyone awake”. When this happened, there’ be slightly embarrassed laughter and a few heads would turn to look at mum. Who ignored it. It doesn’t happen so often any more That was me writing about Women in Open Source in 2005.

Freedom is in Peril

I’ve just written my first ‘real’ real post for the new Freedom is in Peril website. I’ll try and keep the political stuff on that blog from now on, but if you’re at all concerned about the erosion of what has traditionally, if cornily, been called “British Liberty”, then I hope you’ll swing by, and link to, the new site.

Test::Class::Sugar released

I’ve just pushed the second version of Test::Class::Sugar (first discussed here). It’s pretty much as discussed in the original article, but after some discussion with David Wheeler, I’ve dropped the +uses clause from the testclass declaration in favour of less DWIMmy (and thus easier to explain behaviour). I’ve also introduced a defaults argument at use time. The only working default in this release is one which lets you specify the prefix used to derive the test class name from the class/module under test.

Keep calm and carry on my eye

This seems like a more appropriate poster somehow: : Can we have this in mugs, t-shirts and other formats please? Thanks to Alan Fleming for pointing it out.

Thinking about the virtues

I got a bit of stick on IRC last night for some of the choices I’d made when I was writing Test::Class::Sugar, in particular because one of the prerequisites is chromatic’s handy and opinionated Modern::Perl module. The ‘controversial’ aspect of Modern::Perl is that, when you use it, your code won’t run on any Perl before Perl 5, version 10. The thing is, I don’t care about older perls any more. Version 10 features like and // are too convenient to fart about writing circumlocutions just to run on a version of Perl that I have no intention of ever using again.

Magic vs Mundane: Keeping them apart

In which your correspondent does magical battle with the guts of Perl and emerges bloodied, but unbowed with a useful principle to code by. Skip to the conclusion if you’re uncomfortable with the guts of the Perl runtime Test::Class had me tearing my hair out earlier. There I was, happily transforming test something { ok 1; }; into something very like[1]: *test_something = Sub::Name::subname( ‘test_something’ => sub : Test { ok 1 } ); through the magic of [Devel::Declare](http://search.

Writing parsers for fun and convenience

One aspect of coming back to Perl for ‘recreational’ programming is that if, like me, you’ve declared war on @_ and boilerplate code, then testing can be somewhat trying. The Perl testing framework that best fits my head is Test::Class, which is an excellent Perlish implementation of xUnit style testing. If you’re unfamiliar with the, library, Ovid is writing what’s shaping up to be an excellent series of introductory articles about it at http://www.

Perl: Test Infected since 1987

Here’s something interesting. This is the test directory from the very first version of Perl, released in 1987 and described by Larry as ‘a “replacement” for awk and sed’. Day one of Perl, and we already have the bare bones of the Test Anything Protocol and a prototype for Test::Harness in the TEST file. If we truffle about in the various other branches we find other useful milestones for module developers:

A tip for all programmers

It doesn’t matter what language you program in, there’s one very important thing that you should do if you want to get better at your craft. Read. The. Fucking. Manual. Seriously. Tutorials are good. Blog articles can be good. Code snippets are probably better than a poke in the eye with a fecally decorated sharp stick. But the language reference? That’s gold. Read the docs. Read the source. Whatever you do, get the fundamentals down.

Things that may inspire me to hunt and kill you

Let’s say you’re writing a ruby library. Something you want and expect others to use. Here’s how to reduce those others to incandescent rage: require ‘rexml’ include REXML module MyShinyModule … end No. Not no how. Not never. You just crapped in my namespace and stomped on who knows how many of my own classes. Now, include is a fine and dandy thing, and it certainly has its uses, but using it at the top level of your library files is not one of them.

Modern Perl

One of the people who make me think that Perl is still worth knowing is chromatic, the ex-editor of O’Reilly’s He’s one of the core team who are working to bring the Perl 6 Christmas, a vector of test infection, an extreme programming practitioner and, right now at least, no longer on Giles Bowkett’s christmas card list. When I wrote the Healthcheck: Perl for (oh ghod, they’ve rebranded) The H, I mentioned that O’Reilly hadn’t announced Perl: The Good Parts yet.

Moose for Ruby programmers

‘Moose for Ruby Programmers’ was the programmed title for the talk I gave at the technical meet on Thursday, but that was something of a stalking horse for the real title, but I’ll save that for the end of this writeup. Why Ruby? I’ve said this before, and I’ll no doubt say it again, but the main reason I started programming in Ruby was that I got fed up of unrolling @_.

Marking time...

So, it turns out that there’s a recording of my MooseX::Declare talk at the techmeet last night. And, on listening to it, I sound rather less incoherent than I thought I did while I was delivering it (still plenty of places where I could improve. Must remember to always repeat the questions in full…), but I’m happy enough with it that I’m looking into synching it up with the slides and making a slidecast, which will probable take longer than is sensible.

Choosing a language for 2009

The Prags will tell you that you should learn a new language every year, and I think they have a point. This year though, I’m going to do things slightly differently. If you read the Healthcheck: Perl article I wrote for Heise Online then you’ve probably worked out that my language for 2009 is Perl 5, version 10 (hopefully it’ll be version 10.1 real soon now). I’m still paid to write ruby for AmazingTunes in my day job, but Perl’s the language I learned to program with and developments around Moose and its extensions mean that Perl in 2009 is a different language from the one I pretty much stopped using a couple of years ago.

It's not just modern music Giles...

Giles Bowkett’s just written up an example of the way that sampling is an essential part of modern music and he’s right. But he doesn’t go far enough really. Sampling has always been an essential part of all musics. What’s the twelve bar blues form after all? Different artists put their own spin and lyrics on top of it, but it’s always the same chord structure and it’s often the same words forming the backbone.

Warnings are the new test failures

Have you ever tried to run Rails, Rspec, Rake or, for that matter almost any Ruby library or application that you’ve ever heard of with the -w flag? How about running Rails with taint checking on? They aren’t exactly pleasant experiences. Meanwhile, over in Perl land, it’s a very rare module indeed that isn’t at least clean under -w and, where appropriate, taint friendly. It would be a very irresponsible Perl Monger indeed who wrote a web framework that didn’t assume it was going to be running under the -T flag.

Maybe time to look at shoulda

So, because I’m sure that there’s a better way of drying up my rails apps, I’ve been porting Magritte to Ruby (given a good metadescription of your models and judicious application of the visitor and interpreter patterns, it’s amazing what you can do). Now, Magritte comes with a pretty decent test suite in its Smalltalk box. However, that test suite makes serious use of inheritance. Several tests of the leaf classes in the Magritte description hierarchy define maybe three helper methods which parametrise the tests they inherit from their parent test suites.

Javascript heresy

So, remind me, what’s the rationale for always using the optional ; when you’re writing Javascript? The only reasons I can think of, off the top of my head are, “Because you’ll break minifiers without it” and “Because Douglas Crockford doesn’t like it”. Well, broken minifiers that can’t parse the language correctly can kiss my fat hairy arse and argument from authority cuts little ice here. Gareth Rushgrove pointed me at [an article](http://icanhaz.

I think I'm in love with an Axe

<param name="movie” value="”><embed src="” type="application/x-shockwave-flash” allowfullscreen="true” width="425” height="344”> We’ve just spent the weekend on one of Robin Wood’s spoon carving workshops, which was my 41st birthday present from Gill. It was great fun, if a little tiring. There is something primally satisfying about turning a piece of wood into woodchips. Getting a spoon or spatula at the end of the process is a huge bonus. We came away with a bag full of more or less decent treen, a couple of woodcarving knives and a burning desire to own one of Robin’s small drinking vessels.

Just a thought

There’s a refactoring principle that states that, when you start doing the same thing for the third time, you should refactor to remove the duplication. I’m starting to wonder if there’s a Smalltalk principle which states that, when you start doing the same thing the second time, you should search the image for the obviously named method (or use the method finder to find some candidate by feeding it some inputs and an expected answer), because the odds are good that it’s only the second time for you - it might be the millionth time for the image you’re working in.