Jason Gottshall wrote:
> Looks cool, Andy. At the risk of sounding ignorant, can you help me 
> understand how Badger differs from Moose[1]? (other than height, weight, 
> diet, coloration, presence of antlers, and Linnaean taxonomy, of course :-)

That's a good question.  Unfortunately you've used up all the good answers
I had  :-)

I'll try and list some of the similarities and differences that I'm aware
of.  But bear in mind that I know Badger a lot better than I do Moose so
my position may be slightly biased (not that it's a competition or anything).

Some of the similarities:

    * Both provide a more robust object layer on top of Perl 5

    * Both use metaprogramming to achieve those goals (although to
      different degrees)

    * Both are named after cool animals

Some of the differences:

    * Moose sets out to implement the post-modern Perl 6 object model in Perl
      5. It uses a lot of clever magic to make that happen.

    * Badger implements a "regular" Perl 5 object model, albeit a thoroughly
      modern one.  It's got some of the goodness that Perl 6/Moose have, but
      not all of it.  Behind the scenes it is *only* using standard Perl 5 OO
      techniques and little in the way of trickery.  In that sense, Perl5 is
      vanilla, Badger is strawberry and Moose/Perl6 is neapolitan.

    * Moose is more framework, Badger is more toolkit.  One of the
      important principles with Badger is that you can use just one
      module (say, Badger::Base or Badger::Factory) as a regular Perl 5
      OO module, without having to use any of the other modules.  Badger::Class
      provides the metaprogramming side of things to make life easy if
      you want it, but you can manage just fine without it.  On the other
      hand, Moose *is* metaprogramming.  If you don't use the metaprogramming
      wide of things then you're not really using Moose.

    * Moose is "just" about providing an OO framework.  Badger provides the
      OO bits as part of a collection of generally useful modules for
      application authors (me in particular).  Badger contains the things
      that I need for TT, and the kind of things that I find myself writing
      over and over again in pretty much every Perl project I work on.  So the
      Moose-like (and Spiffy-like) parts of Badger are a means to an end,
      rather than the raison d'etre in themselves.

    * Badger has no external dependencies.  In the general case that's
      probably not something to be proud of (reuse is good, right?)
      But in the case of TT (and some other projects in the pipeline), having
      as few dependencies as possible is really important.  If you can't
      install it then you can't use it, and there are quite a few TT users
      for whom installing something from CPAN is not an option, either because
      their ISP won't allow it or they're incapable of using a command line.
      (Mr T pities those fools, but we try to help them, not berate them).

I'm sure there are other similarities and differences.  I'll probably think
of another few just after I hit "send". But in the end, there's no competition
going on and no hidden agenda for Badger world domination (same goes for Moose
AFAIK).  They're similar, but different.  And there's no reason why you can't
use both.  Badger plays nicely with Moose.

I take a rather artistic view to software construction - it's like any other
design process where you try to balance form and function.  Sometimes the
drive to develop a new "product" comes from a functional requirement: the
existing widget doesn't work very well so you design a better one.  Other
times it comes from an artistic streak: it's not that the widget doesn't
work, it's just that you would have done it *different*.

Badger is a bit of both.  When I started work on TT3 there was no Moose
so I had to write my own (or bits of my own).  Those bits of code then got
used in numerous other projects (mostly commercial projects for other people)
while TT3 stagnated somewhat (sorry, but I gotta pay for the roof over my
head and to keep the food on the table).  So I ended up "forking" my own
internal codebase several times over.  When I sat down to finish off TT3
in March/April of this year, I realised I had a whole bunch of updates from
"out in the field" that I needed to roll back into the core TT3 modules
(Template::Base, Template::Class, Template::Utils, Template::Constants, etc).
But I decided that enough was enough and that it should be released as a
stand-alone module set.  Yes, I know I should have done it years ago, but it
wasn't done years ago so I couldn't :-)

Of course Moose had come along by then (among others) and I seriously
considered using it.  But the dependency list is long and although reliable,
it is still rather experimental (in the sense that it's implementing the Perl
6 object model).  @Larry could change his mind tomorrow and Moose
will (presumably) change to follow suit.  Right now I'm less concerned about
what Perl 6 is doing and more concerned about getting this job finished
today in Perl 5.  Switching to Moose would have meant another huge code
overhaul and a number of changes to my way of thinking that I'm not ready to
make yet.

The other thing worth mentioning is that Badger is a replacement for (or
at least, supercedes) Class::Base and Class::Singletonp.  I would rather
maintain a single Badger collection that a bunch of searate Class::*
modules.  Apart from anything else, it allows them to share common
functionality (e.g. an exception class for error handling) without having
to create a third (fourth, fifth) external module and/or add more
dependencies.  On that level, Badger has a bit more of the "batteries
included" mentality of Python.  It's about pulling a bunch of modules together
into one happy family with consistent functionality, usage, API,
documentation, and so on.

So to sum up, Badger and Moose do some similar things but in different ways.
They both like to forage in the forest for nuts and berries.  The Moose picks
them off the trees and the Badger gets them off the ground.

Moose rocks.  Badger rolls.  TMTOWTDI.

HTH
A



_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to