Hacking on Dancer

If you're not familiar with Dancer, it's a Perl framework written by Alexis Sukrieh and inspired by Ruby's Sinatra framework. Though some call it a "micro-framework", according to Wikipedia, Sinatra is used by Apple, BBC, the British Government, LinkedIn, Engine Yard, Heroku, GitHub, and Songbird. That impressive list shows that Sinatra, and thus Dancer, is far more powerful than you might think at first glance.

So far, while I love Catalyst, I've found that I'm hacking out a Web service much faster with Dancer than I would have with Catalyst and I used Catalyst quite a bit. I've submitted a couple of minor patches, but I'm very happy with my latest enhancement to Dancer.

I was working on the authentication mechanism for a real-time bidding system I'm developing when I was trying to puzzle through a test failure. Eventually I tracked it down to this:

my $password = config->{auth}{pass};

After finishing my patch, when I included "strict_config: 1" in the config, it became:

my $password = config->auth->pass;

And that generates the following error:

Can't locate config attribute "pass".
Available attributes: password, username

Which makes it clear that what I really want it:

my $password = config->auth->password;

I love how simply Dancer is and how easy it is to use. Plus, the codebase is very clean and easy to follow. And it's small enough to easily wrap my head around it.

Here's a simple Web application that Ævar Bjarmason wrote in Dancer.

Leave a comment

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/