[cgiapp] Dancer
Perrin Harkins
pharkins at gmail.com
Thu Feb 25 21:49:21 EST 2010
On Thu, Feb 25, 2010 at 6:51 PM, P Kishor <punk.kish at gmail.com> wrote:
> So, my question is thus -- how is Dancer different from CGI::App, and
> why should I use the latter instead of the former? I asked this not
> lightly because I have many years of experience invested in C::A, but
> Dancer truly shows how apps should be.
I haven't used Dancer, but I can tell you a few things about the
example code in the docs that rub me the wrong way. Here's a small
piece:
get '/hello/:name' => sub {
return "Why, hello there " . params->{name};
};
Note that get() is imported. I hope you never want a method called
get() in code that uses Dancer (or set(), since that's used for
something else). In fact a large number of keywords are imported, as
you'll see if you look at @EXPORT in the Dancer.pm source.
What's the syntax here? It doesn't really look like valid perl, does
it? It's really doing this:
get($url, $sub_ref);
So, it's kind of sneaky, which is another thing I don't like to see in
code. The params thing (it's a function that reads the current
request from a global) is also sneaky for no good reason IMO.
I don't think I'd enjoy writing a lot of code in sub refs either,
especially not when trying to run a profiler or the debugger on them.
I suppose you can get around that with a CGI::App-style construction
like this:
get('process_form' => \&process_form);
sub process_form {
[...]
}
OTOH, there are definitely some nice-looking things about this
package. It has a good amount of docs for a new distribution, a lot
of tests, and the code style internally looks good and easy to follow.
It's really just the syntax and the namespace pollution that bother
me.
- Perrin
More information about the cgiapp
mailing list