September 2012 Archives

Ooh, pretty!

CPAN Ratings has had a face lift.

Creating Your Own Perl

Perl modules are not like dynamically loaded libraries in other programming languages. Thanks to the import function, sub prototypes, symbol table hacking, parser hooks, magic like Devel-Declare, ties and other voodoo, Perl modules can shape and craft the flavour of Perl that is available to their caller. A practical example: Perl's exception handling via eval and $@ is weird, clunky and error-prone. But by loading /users/toby_inkster/2012/09/index.html

Moving to Moose Hackathon 2012 Roundup

OK, so another MTMH 2012 blog post. I'm trailing far behind everyone else, but better late than never.

MTMH 2012 was a joint hackathon between the people working on p5-mop (a project to get a Moose-lite metaobject system into the Perl 5 core) and the Perl RDF toolkit, with a few Rakudo people thrown in too, ostensibly for convergence between the p5-mop and Perl 6 metaobject systems when possible. As somebody in the RDF camp, though with a toe in the Moose water, I decided to get a better feel for Moose by playing around with a few MooseX projects. (The results include MooseX-DeclareX and MooseX-Interface.) There's really a lot of cool stuff behind $self->meta. If you've never gone behind has, extends and with when using Moose, you really should.

Transport to the venue was fairly uneventful, which is always a good thing. I was on the same physical aeroplane for the Gatwick-Oslo and Oslo-Stavanger flights, yet at Oslo I had to get off, go through passport control, customs, airport security, etc, which was quite a challenge in 45 minutes. Apparently four people (not on the hackathon) doing the same dance didn't quite make it in time and missed the flight. It was a wise decision to only bring hand luggage. In-flight reading was Statistical Linked Dataspaces. Had a good meal at the lodge and an interesting talk about RDF with Greg and Stevan.

Day one was the hike up Preikestolen where I discovered that Nick Perez is some kind of secret mountain goat in disguise. The trip probably hit hacking productivity quite hard as most of us just wanted a nap when we got back.

The next day was Monday, and we had a couple of interesting talks, and discussed the Moosification of RDF-Trine in very general terms. I managed to push out a couple of Moose-related CPAN releases; one was a first public version of the MooseX-RoleFor distribution that had been sitting half-formed as a development version on CPAN for many months.

Eventually we came up with a concrete plan for RDF-Trine. Greg took on refactoring the RDF store API using Moose roles; Kjetil looked at namespace handling; Konstantin worked on getting us a solid type constraint library (mostly ported from his MooseX-Semantic; and I handled nodes and statements (the building blocks of RDF data). I'm also pencilled in for iterators, but that's a big task that I've barely scratched the surface of so far. Chris advised on various Moosification issues, including the invaluable idea to name Moose roles something with "::API" in them.

Ruben meanwhile (with help from Shawn Artak) managed to improve RDF-Trine's Turtle parser's performance by not one, but two orders of magnitude, so that we were in the somewhat bizarre situation of having faster Turtle than N-Triples parsing. (He later turned his attention to the N-Triples and N-Quads parsers.) Not bad for somebody who only started learning Perl in July!

On Wednesday, Konstantin and I got some pretty solid hacking on the RDF-Trine parser and serializer APIs done. The main change is to introduce objects representing file formats. Parsers and serializers are then subservient to those. Though there are convenience constructor methods for parsers and serializers that allow you to use them without knowing anything about format objects and the format registry. The format registry also provides a convenient place for other file-format-specific processors to hook into - syntax highlighters, linters, etc.

Our constant companions during the hackathon were some small insects the Norwegians refer to as knott... effectively micro-mosquitoes. I've only just stopped itching.

The hackathon was extremely well-organised: there was a mini-bus to ferry people to and from the venue; all the accommodation and food was taken care of; we even had a trained paramedic on hand. There were some minor issues (wifi coverage was patchy at times; the vegetarian options at dinner were often somewhat uninspiring) but overall the event was enjoyable, educational and productive.

The Perl community really needs more of this kind of event - practical get-togethers with focussed topics. did a fantastic job of arranging sponsorship and organising the hackathon. I hope other groups can follow their example. Salve apparently gave a talk at YAPC::EU on running a Perl Mongers group and organising events. (Anybody have a link to slides or notes?)

Future hackathons I'd like to see happen:

  • An event focussed on closing the gap between Perl 5 and Perl 6. While Perl 5 clearly still has a long future ahead of it, Perl 6 needs to be taken more seriously as the direction Perl is heading. If practical, we should be looking at backporting features from Perl 6 to Perl 5, not just because it has an awesome feature set, but to help ease transition.

    More importantly Rakudo and Niecza need to be able to run Perl 5 code. Perl 5's biggest selling point is not its syntax, or its object model or even its regular expression engine. Perl 5's big selling point is CPAN. 80% of your application is already written. Until Perl 6 can offer that, Perl 5 is going to seem like a more attactive proposition to most people.

  • Another Perl RDF hackathon would be great. We've had two now, but there's still so much that could be done. Perl is said to be a multi-paradigm language allowing object-oriented, functional and procedural programming techniques to be mixed with ease. The one paradigm it hasn't really delivered on is logic programming (think: Prolog). A fast OWL reasoning engine would be a great boon to Perl. Particularly if something like MooseX-Semantic were able to bridge the gap between Moose objects (i.e. instances) and OWL ontologies. But we're still a long way off that.

  • A BioPerl / scientific Perl hackathon would also be an interesting topic. (RDF is also widely used in the life sciences world so it might be good to colocate that with Perl RDF.)

We had some really great developers at MTMH 2012, partly down to the careful scheduling (the hackathon started a couple of days after YAPC::EU). If you're willing to organise an event such as this, it can be a productive and enjoyable endevour. As Jim told Wayne, if you book them, they will come.

This article was originally published at

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.