Blog Posts

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Keep calm and carry on my eye

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

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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:

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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 perl.com. 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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Moose for Ruby programmers

‘Moose for Ruby Programmers’ was the programmed title for the talk I gave at the London.pm 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 @_.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Marking time...

So, it turns out that there’s a recording of my MooseX::Declare talk at the London.pm 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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

I think I'm in love with an Axe

<param name=“movie” value=“http://www.youtube.com/v/Lx-NTPBoLmU&hl=en&fs=1"><embed src=“http://www.youtube.com/v/Lx-NTPBoLmU&hl=en&fs=1" 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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

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.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

And if there were, what then?

The Alpha Course people have been running a bunch of poster ads built around the slogan “If God did exist, what would you ask?”. The posters are filled with anodyne questions like “What’s the point?” or “Is this it?”. They also tend to have large amounts of white space on them - I’m sure there are enterprising graffiti artists out there who look upon that as a fine opportunity. So, here’s a few questions I’d ask god, if it existed:

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions