- WHY IS THIS
- SEE ALSO
Mite - Moose-like OO, fast to load, with zero dependencies.
$ mite init Foo $ cat lib/Foo.pm package Foo; # Load the Mite shim use Foo::Mite; # Subclass of Bar extends "Bar"; # A read/write string attribute has attribute => is => 'rw'; # A read-only attribute with a default has another_attribute => is => 'ro', default => 1; $ mite compile
Mite provides a subset of Moose features with very fast startup time and zero dependencies.
This release is a proof-of-concept. It is to gather information about the basic premise of a pre-compiled Moose variant and gauge interest. It is missing a lot of features, they'll be added later if Mite proves to be a good idea. What it does have is well tested.
Mite provides Moose-like functionality, but it does all the work during development. New source code is written which contains the OO code. Your project does not have to depend on Mite. Nor does your project have to spend time during startup to build OO features.
Only developers must have Mite installed. Install it normally from CPAN.
Do not declare Mite as a dependency. It is not needed to install your release.
Initialize your project. Tell it your project name.
This will create a .mite directory and a shim file in lib.
use Mite, you should
use Your::Project::Mite. The name of this file will depend on the name of your project.
Mite is "compiled" in that the code must be processed after editing before you run it. This is done by running
mite compile. It will create .mite.pm files for each .pm file in lib.
To make development smoother, we provide utility modules to link Mite with the normal build process. See Mite::MakeMaker and Mite::ModuleBuild for MakeMaker/Makefile.PL and Module::Build/Build.PL development respectively.
The .mite directory should not be shipped with your distribution. Add
^\.mite$ to your MANIFEST.SKIP file.
The compiled .mite.pm files must ship with your code, so make sure they get picked up in your MANIFEST file. This should happen when you build the MANIFEST normally.
Build and ship your distribution normally. It contains everything it needs.
Works as in Moose. Options are not implemented.
Mite will turn strict on for you.
Mite will turn warnings on for you.
Mite writes pure Perl code and your module will run with no dependencies. It will also write code to use other, faster modules to do the same job, if available.
These optimizations can be turned off by setting the
MITE_PURE_PERL environment variable true.
You may wish to add these as recommended dependencies.
Mite will use Class::XSAccessor for accessors if available. They are significantly faster than those written in Perl.
This module exists for a very special set of use cases. Authors of toolchain modules (Test::More, ExtUtils::MakeMaker, File::Spec, etc...) who cannot easily depend on other CPAN modules. It would cause a circular dependency and add instability to CPAN. These authors are frustrated at not being able to use most of the advances in Perl present on CPAN, such as Moose.
To add to their burden, by being used by almost everyone, toolchain modules limit how fast modules can load. So they have to compile very fast. They do not have the luxury of creating attributes and including roles at compile time. It must be baked in.
Use Mite if your project cannot have non-core dependencies or needs to load very quickly.
Mouse is a very fast and rather complete subset of Moose with no dependencies.
Moose is the complete Perl 5 OO module which this is all based on.