Hacktivity report (Jan-Mar 2012)

Perinci

For the past 2.5 months I mostly worked on converting my old Sub::Spec::* modules to the new Perinci::*. Sub::Spec is a mix of specification, convention, and tools to let you decorate functions with documentation as well as everything else, but most commonly argument specification and feature description. This decoration can in turn be used to do various things, from generating POD, to validating arguments, to shell completion.

The reason I picked a new name for the modules is because I want to decorate other code entities too, like variables and packages, thus the prefix "Sub::" is no longer apt. I also took advantage of this opportunity by introducing some backwards-incompatible changes like the change to schema of arguments specification. The specification is now separated more formally into Rinci (a la PSGI vs Plack) where the Perl implementation is called Perinci, short for "Perl Rinci". I envision Pyrinci, Rubinci, and Phinci seeing the light of day someday, though that would most likely be due to the effort of others.

So this work began in the middle of January and was finished yesterday. I went through the boring process of converting module by module (there are around 20-25 modules in total, with around 1000 commits). In the end I ended up with roughly the same set of modules, but I am glad because these new functionalities got in:

  • More transparent remoting. Everything is URL-based, remote functions can be handled more like local functions. We can do bash completion of remote function arguments, for example.

  • The specification (1, 2) is extensible. Implementation can add more actions on the server side. The client side can request the list of supported actions on the server.

  • Direct TCP server. Okay, this is just a specification without implementation for now, but implementing this should be easy.

  • Command-line framework is now OO and more easily extended.

  • The subroutine wrapper is also more properly extensible now. It also has feature to convert Sub::Spec specs to new Rinci metadata, which I'm thankful because I have written a lot of Sub::Spec specs.

  • Documentation-generating tools are now translatable, using Locale::Maketext.

Others

Along with the above, there is the usual list of modules which got created or improved. Notable ones include:

  • Module::Patch (new). I maintain a couple of patches for other CPAN modules, and until the patch got merged (if ever) and a new version module got released, I have to manually patch the module and distribute my tarballs to deployed systems. Got sick of that pretty quickly and thus modules like HTTP::Daemon::patch::ipv6 and LWP::UserAgent::patch::https_hard_timeout were born. They use Module::Patch to help make monkey patching a bit safer.

  • Passwd::Unix::Alt got some attention 2 weeks ago, with some patches and additional tests from Christian Kuelker. I also added in optional file locking, but this caused a bunch of test failures which I haven't got the chance to look into, so I set locking off by default.

  • Log::Any::App got some new environment variable settings to make it easy to show category in the log messages, as well as setting category aliases/levels so that we can filter showing logs from some modules, right from the command line. There is also a long standing bug where duplicate log lines are printed, but so far it hasn't irked me too much to fix it. I'm, as always, more annoyed with the noticeable startup slowdown whenever I use Log::Any::App (due to Log::Log4perl) but I really don't have the tuits to prepare a new backend.

  • Finance::Bank::ID::BCA was broken for a while due to the bank servers now rejecting TE request header. Gisle Aas helped by pointing out that LWP can be instructed to not send this header, so now things are back to normal.

  • Setup. I also separated this specification from the implementation. Nervously awaiting someone to blast me for occupying a rather generic top-level namespace.

Next work

I'm relieved that the migration to Perinci::* is done. All of my modules on CPAN that use Sub::Spec::* have been updated to use Perinci::*. The old modules have also been purged from PAUSE. I now plan to work on a form framework (that will also utilize Rinci/Sah) so I can finally start writing web applications in Perl again after years of doing them in PHP.

Leave a comment

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays). My CPAN ID: SHARYANTO. I'm sedusedan on perlmonks. My twitter is stevenharyanto (but I don't tweet much). Follow me on github: sharyanto.