The following is an edited and updated version of a Moose advocacy bit I wrote on the Google AppEngine for Perl project mailing list quite a while ago. I decided to republish it here since with the recent release of Catalyst 5.8, which uses Moose as a core technological foundation, I felt it would be a good idea to reflect on why I think this is a great thing. There are quite a few tutorials and code overviews for why Moose is a superior object system (links at the end of the article) but I don't see many postings that are simple reflections on Moose and why I, as a developer, am happy it belongs to Perl.
I also think the Google AppEngine for Perl project is not getting nearly enough love and I'm hoping to draw a bit of attention to it as well.
You can read the original here, but that version has an embarrassing number of spelling and grammar errors :)
Without Moose, I'd probably have lost the faith and left Perl for another language. This is not a lightly written statement, since I've been using Perl as a primary server side development language since 1996. When I first started programming I gravitated toward Perl for two reasons: First, it let me do what I needed to do without getting in the way or forcing me to jump through a lot of hoops. Second, it introduced me to what is now broadly thought of as the Open Source community, an idea of how software development and knowledge sharing could be that excited my idealistic nature. I have to imagine there are quite a few programmers in Perl with a similar story. A lot of us started using Perl because the module CGI made it trivial to create server side web forms, while DBI created a straightforward means to shuffle information between the web and back end databases. Perl did what I needed it to do.
However, over the time, my love affair with Perl diminished. Perl's default Object Oriented system is very minimalistic and I found myself envious of languages that allowed --and even encouraged-- a best practices approach in modeling your application. For the first time I started to feel like Perl was getting in the way of me just doing what I needed to do, mostly because I was spending a lot of time jumping through hoops and not expressing my problem domain. Even worse, this lack in Perl caused many large projects to create there own ways to close the gaps left open by existing methodologies. How many different and incompatible component systems have been written for Perl? How many systems for making it easier to do object oriented programming? And each time you go to load a new module from CPAN, you end up also loading a bunch of dependencies for yet another half baked OO framework that is only being used on a handful of projects. This reality makes it much harder for newcomers to usefully contribute code, since each time you have to learn a new underlying framework and all its idiosyncrasies. That's why most important Perl CPAN modules have at most a small handful of contributors. Worse, if fed the common belief that Perl is spaghetti code not suitable for larger applications. Now, I do think having competing ideas is good, and that value is one of the things that makes Perl strong, however for basic, core programming tasks the lack of consistency really hurts us. Where would Perl be if CGI had not been so complete, or if DBI did not become the dominate method of accessing databases?
Moose has reinvigorated my love for the Perl language, it's community and programming in general. It cleanly solves the problem of Perl's minimal OO features. I write less boilerplate and spend more time expressing my problem domain. It provides a wealth of expression around which a rich economy of best practices and shared solutions can grow. Additionally, since it's written for programmers by programmers, I find that it fits my brain better than any other ivy tower OO solution. It has a large and growing community of active developers, more than any other competing system OO framework for Perl AFAIK. Lastly, some of the most important Perl projects of our day, such as Catalyst, DBIx::Class, etc are either using Moose or moving toward Moose. For me, Moose makes OO Perl just as expressive and fun as I found Perl to be when I first started writing website applications all those years ago.
Is it perfect? No, certainly there is a lot of room for Moose to improve. However, all the right decisions to let those improvements happen have been made. The developer community is very serious about feature enhancements and about growing adoption of the framework as well as growing the number of contributors. I am a case in point, since although I've been using Perl for more than 10 years, Moose is one of a small number of projects that I've managed to become involved at the contributor level. Moose not working the way you need it to? That's fine, come to IRC and make your case. However, I would encourage to do your homework first, since the Moose channels have some of the brightest minds I have ever had the chance to see in action.
For me, properly written Perl starts with Moose. It should serve as the basis for any serious project you may be about to undertake.
- For more about Perl.
- For more about Moose.
- The Official Moose Learning Manual
- For more about the Google AppEngine for Perl project.