Trying out Mojolicious

By Abhijit Menon-Sen <>

For the first time in many years, I have a new web project to work on (and perhaps it goes without saying that I need to finish it quickly). Much has changed in the world of web development with Perl since I was last seriously involved, and it took me a while to find my bearings.

When I last worked on a major new web project, none of today's popular web development frameworks existed. Tangram was the shiny new ORM (but I can't remember hearing either "ORM" or "CRUD" back then), and ePerl was my favourite out of perhaps half a dozen templating modules on CPAN. Both have long since been forgotten, and I set out to find something to replace them. I had a few specific ideas about what functionality I wanted, but I suppressed my "not invented here" tendencies and decided to accept any reasonable way to implement them.

The first thing I tried was Jifty, whose basic premise I liked and whose developers I respect. I'd played with it when it was first released, and although I knew there were some things about it that I didn't like, I expected to get along with it well enough to use it in a few projects. I waited while its myriad dependencies were resolved, fixed a couple of dependency-version-related problems, and set out to build a prototype.

Unfortunately, I found Jifty too big to wrap my head around in the time I had, and there just wasn't enough documentation to help me. I know it is actively developed and in use at BestPractical, but I was discouraged by the broken image links on the wiki (no diagrams that may have helped me make sense of things) and the mostly idle IRC channel. Many of the tutorials were either fairly trivial or out of date; and the most detailed one was for a non-trivial project that had later switched to Catalyst. Still, I stuck with it for several days before reluctantly deciding to move on when I couldn't figure out how to implement features I needed and solve problems I encountered along the way.

I knew a number of people who were happy with Catalyst, so I tried that next. It brought with it another set of dependencies, and a lot more documentation. I learned enough about the Catalyst core to decide on a sensible structure for my second prototype, but I found myself lost in a maze of plugins when it came to implementation details. I could never be certain which of the dozen wildly different ways to do any given thing was most appropriate; and once again, features I wanted turned out to be hard to achieve with the most commonly-used and best-maintained plugins. I gave up when I found myself implementing most of the CRUD handling code I needed from scratch. (I also found that I liked DBIx::Class no more than I'd liked Jifty's DBIx::SearchBuilder, which wasn't very much at all.)

By now thoroughly disappointed, I looked for other alternatives and stumbled across Mojolicious and Dancer, two superficially very similar projects that provided only convenient request and response handling in a neat little package. I played with both, and read Adam Kennedy's comparison of the two. I started with Dancer, but ended up choosing Mojolicious for various reasons. First, it had no dependencies other than core Perl (which was an attractive proposition after hours spent installing Jifty and Catalyst). Second, it provided single-file Dancer-like syntax sugar in Mojolicious::Lite, but also offered a way to move beyond that and write a more structured app. I also liked its default templating system (whereas I'd never really liked Template Toolkit, which Dancer prefers). Despite some initial misgivings, once I started using it, I kept finding little reasons to like it.

I'm using Mojolicious (not ::Lite) for my project, and I'm happy so far.