Is Moose a Framework?

Ovid on 2007-09-30T18:53:17

According to Wikipedia, a software framework is (emphasis mine):

A software framework is a re-usable design for a software system (or subsystem). A software framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. Various parts of the framework may be exposed through an API.

I don't think that this is a great definition, but at its core, a software framework seems to be a system which factors out some of the common components of an application and allows developers to focus on the application logic. It appears that people strongly disagree with me. BrowserUK stated:

(IMO) the key element of a framework is that it provides the structure of an application and leaves the application programmer to fill in the details of the specific application.

This sounds suspiciously close to my definition, but as far as I can tell, the key point is that most people feel that frameworks are targeted at specific types of applications (Web sites, ORMs like Hibernate), rather than at general types of applications. By this distinction, Stevan Little's excellent Moose distribution is not a framework, even though I see it as a "Perl 6 OO framework for Perl 5". Because it's general-purpose, it doesn't get to call itself a framework. Never mind it is a "reusable design for a software system", it doesn't get to belong to the framework club.

In the Perlmonks thread I linked to earlier, tye made a distinction between "application framework" and "library framework", though he didn't see the latter as being a useful term. I think I'm inclined to agree with him on that now. Though part of me balks at saying "general purpose code is not allowed to be a framework", I think I'll bow to consensus and agree that I was wrong. Oops.


"Framework" is a loaded term these days

Stevan on 2007-09-30T22:12:00

I personally think that the word "framework" is a heavily overloaded term these days. If I were to give my own definition (which is surely not the correct one, only how I personally view them) it would be "a collection of software libraries that you work /within/ to create an application". By "within" I mean that the set of libraries tends to envelop your code in such a way that the end user/consumer of your code rarely has direct connection with your code itself, but instead iteracts with some layer of the framework instead. This is most obvious in something like Catalyst in which the details of URL dispatch, Template creation (almost always automagically handleded by the View class) and request parameter processing are all largely handled for you.

By this definition (which I admit is very broad), Moose is a framework. It is a framework for doing OO programming (yes, very Perl6-ish OO). But (as you correctly point out) I dont anywhere call it an "OO Framework", because I don't look at it that way. I see it as an OO "system" which itself then becomes an "extension" of the language itself. This is very much how I have heard CLOS referred too, which is suprising given how heavily CLOS influenced the design of Moose and Class::MOP. It was also a big design goal of Moose that it not force you to do everything "The Moose Way", but allow you to use as much or as little of Moose as you needed.

Now, one small thing I would like to point out. We do mention the word "framework" in the latest release. Chris Prather did some excellent fiddling with some of the internals of Moose.pm and was able to expose some of goodness of the Sub::Exporter module (which we use to export Moose's "keywords"). The result is that it is much much easier to "extend" Moose and even "embed" Moose within your "framework" (see the EXTENDING_AND_EMBEDDING_MOOSE section of the docs). In this way you could look at Moose as a "meta-framework" which you can use as the basis for your own framework.

- Stevan

Inside-out vs outside in

Alias on 2007-10-01T19:40:12

A library proves a piece of functionality that can be dropped into a program.

A framework defines the outside boundaries of the problem to be solved, and assists in the solution.

Library is like this...

Framework is like this

|-->FRAMEWORK...PROBLEM...FRAMEWORK--|

The key distinction here for me is that if you use a bad library, you can swap it out for a better one.

If you hit the limits of your framework, you are in much bigger trouble.

Re consensus

blazar on 2007-10-02T09:15:34

As far as consensus is concerned, FWIW let me tell you that I agree with you. Or is that the "old" you, now?