Photograph of an adorable baby-velocipactor toy, posed on a rock against a green, leafy background.
“JPTLW Baby Raptor” by Sarah Darwin is licensed under CC BY-NC-ND 2.0

I read and enjoyed brian d foy’s Mojolicious Web Clients, a short and direct guide to writing command-line utilities using the open-source, Perl-based web toolkit called Mojo. (The title’s “Mojolicious” formally refers to a full-featured web framework built on Mojo, but I am told that the longer name now embraces both the toolkit and the framework, per the project’s official website.)

I’ve worked with Mojo for a couple of years now; my Webmention library relies upon its wonderful DOM parser, for example. But I didn’t really understand the project as a whole; while it does offer higher-level guides to complement its voluminous nuts-and-bolts reference material, it has always lacked the slower, fleshier explanatory power of a real book. As such, I hungrily purchased foy’s new e-book the moment I learned about it. Even though it covers just one aspect of Mojolicious — using its toolkit to request and extract interesting data from the web, whether via JSON-based APIs or human-intended HTML pages — it still provides very welcome long-form documentation coverage to a project that has long deserved it. I hope similar books follow.

Mojolicious Web Clients tours through major Mojo concepts over a few short and example-heavy chapters. After spending a few evenings working through it, reading slowly enough to get the gist of all its code examples — taking notes and occasionally keying them in to run my own experiments — I have a much more complete understanding of Mojo’s structure, power, and philosophy. For example, the purpose of Mojo “collections”, an object-oriented reimplemnentation of Perl’s built-in array structures, no longer eludes me. And I understand why Mojo cheerfully stole “promises” from JavaScript, allowing one to write conceptually tricky non-blocking code in a fluid and readable way; now I itch to add this technique to my own projects.

Prior to reading this book, I felt quite foggy on the difference between the Mojo toolkit and the Mojolicious framework, vaguely understanding the latter as a followup to the venerable Catalyst framework, and knowing that CPAN hosted a variety of modules under the “Mojo” namespace but not seeing any particular pattern to them. Happily, foy’s book opens with a history of Perl-based web tools right up through the present, clearly explaining how Mojo has picked up the torch from the long-lived LWP library, and going on to demonstrate its commitment to modernization through an emphasis on fluid coding style and strategic wheel-reinvention.

Mojo, apparently, is one of those rare software projects that starts over from scratch and gets it right. According to its manual page, Mojolicious has only four library dependencies, and all of them already ship with Perl. A veteran Perl hacker recognizes this as absurd, especially for such a wide-ranging project. It often seems that a typical Perl-based project (any of mine included, certainly) wants to download half of CPAN before it will deign to try installing itself, and so Mojo represents a stunning lesson in dependency-austerity. And as such, of course, it brings both a gift and a challenge: use Mojo in your project, and see how little else you’ll need to get to your goal. You just might write better software for it, with far fewer dependencies outside of your control.

To a Perl fan like me, learning Mojo today feels like both a relief and a necessity. At a time when the lights threaten to shut off over Perl’s role as anything other than small-scale Unix-glue, Mojolicious represents a rare project keeping the party going with inventive and ongoing vitality. I was intrigued when colleagues first suggested the Mojo modules to me two years ago, delighted to find Mojolicious quietly starring in Emily Shea’s 2019 conference presentation about voice-driven programming, and now cheered by the arrival of even one fresh book on the topic. As Brian Wisti recently said, “Mojolicious is why I still have Perl installed in 2020”. I like Perl enough and respect its community, however small these days, that I feel obliged to adapt my own practices to better feed from — and, I hope, feed back into — this valuable source of forward-looking energy.

This article was also posted to the “books” section of

Share or reply to this post on Twitter, or elsewhere.

Next post: I played Root, an asymmetrical wargame

Previous post: My Jan/Feb 2020 TPF grant proposal

Loading responses...

Share a response

To share a response that links to this page from somewhere else on the web, paste its URL here.