Moving to Moose Hackathon 2012

2012-09-01 − 🏷 moose 🏷 perl 🏷 perl mongers

This week, my excellent Perl Mongers group Oslo.pm, led by the excellent Salve,  has arranged an event we called the Moving to Moose Hackathon 2012. The purpose of this event was to promote the adoption of a MOP (Meta Object Protocol) in Perl development. To this effect, we had two groups, the Perl RDF community, looking to adopt moose in their modules, and Stevan Little and his merry gang of p5-mop developers, looking to create a proposal for a MOP in the Perl core itself, to replace the venerable blessed hash object model.

 
Unfortunately due to the arrival of baby Milla in June, I was unable to attend the entire event, which started on saturday. Thus I missed the walk to Pulpit Rock (did I mention the event was smack in the middle of the Norwegian fjords?) Luckily I've been there before (see pic on the right :-). I arrived early Tuesday morning by the night train. On the way there, I re-read the proposal for the p5-mop
 
Pulpit Rock
 
Since I'm not a mad hatter scientist like Yuval and Jesse, and don't know the Moose MOP that well, I concentrated my efforts on tooling and real world triage of the prototype. For me, the most exciting idea of the proposal is adding first class 'method', 'has' and 'class' keywords, so that you can declare Perl classes like this:
 
    class Cat (extends => Animals) {
      has $claws;
      method meow { ... }
    }
 
Since I'm an avid TextMate fan (specially since the Open Source release this fall), I started by extending the TM2 syntax to support these new keywords. This means getting proper highlighting, as well as easy navigation in classes and methods. You can find my fork of the official Perl syntax highlighter here.
 
I then started work on porting a few Mojo base classes to the new syntax. Being one of the Mojolicious core developers, I know these classes rather well, and they have the advantage of being light on dependencies and optimized for easy porting to Perl6, as well as having comprehensive test suites. This made them an ideal target for trying out features of the prototype. 
 
Of course I met some hardship underway. The biggest issue for me during the port was the lack of BUILDARGS, a class method to massage the constructor parameters into a hash, but all in all the experience was quite educational. I also found some small points of improvement in the specifications during my attempts, and submitted a simple doc patch. 
 
Together with Jan Henning, I also looked into the feasibility of supporting overloading in the new p5-mop classes, and Jan Henning ended up writing a new meta class to support this. I believe this should be refactored into a meta role when the mop has been updated with support for that.
 
In the period that I was there, the main p5-mop developers struggled quite a bit with an issue in the dispatching that was giving bizarre errors and was really hard to track down. Unfortunately, this slowed down development, as we were unable to start using the new two-phase bootstrap code which  would allow us much easier development of the meta classes. 
 
However, I was really excited about the discussions about the new 'meta' keyword on the last night of the hackathon to allow meta definitions (and thus class methods, and roles) in the class definitions themselves.  I quite look forward to the updated prototype, and hope to resume my port as soon as BUILDARGS support has landed.
 
I think the crucial question now is if we can manage to maintain velocity in the development of the p5-mop prototype after this hackathon. I truly hope we can start seeing real world usage of it soon. This is the best way to figure out gotchas and problems with the specification before it lands in the core.