NAME
Mite - Moose-like OO, fast to load, with zero dependencies.
SYNOPSIS
Start a project:
$ mite init Foo
Write a class (lib/Foo.pm):
package Foo;
use Foo::Mite;
has attribute => (
is => 'rw',
);
has another_attribute => (
is => 'ro',
default => 'Hello world',
);
1;
Write another class (lib/Foo/Bar.pm):
package Foo::Bar;
use Foo::Mite;
extends 'Foo';
sub my_method {
my $class = shift;
print $class->new->another_attribute, "\n";
}
1;
Compile your project:
$ mite compile
Use your project:
$ perl -Ilib -MFoo::Bar -E'Foo::Bar->my_method'
DESCRIPTION
Mite provides a subset of Moose features with very fast startup time and zero dependencies.
Moose and Moo are great... unless you can't have any dependencies or compile-time is critical.
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.
Mite is for a very narrow set of use cases. Unless you specifically need ultra-fast startup time or zero dependencies, use Moose or Moo.
OPTIMIZATIONS
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 PERL_ONLY
environment variable true.
You may wish to add these as recommended dependencies.
Class::XSAccessor
Mite will use Class::XSAccessor for accessors if available. They are significantly faster than those written in Perl.
WHY IS THIS
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.
BUGS
Please report any bugs to https://github.com/tobyink/p5-mite/issues.
SEE ALSO
Mite::Manual::Workflow - how to develop with Mite.
Mite::Manual::Keywords - functions exported by Mite.
Mite::Manual::Attributes - options for defining attributes with Mite.
Mite::Manual::Features - other features provided by Mite.
Mite::Manual::MOP - integration with the Moose Meta-Object Protocol.
Mite::Manual::Missing - major Moose features not supported by Mite.
Mite::Manual::Benchmarking - comparing Mite with Moose, Moo, and Mouse.
https://metacpan.org/dist/Acme-Mitey-Cards - demo project.
Moose is the complete Perl 5 OO module which this is all based on.
Moo is a lighter-weight Moose-compatible module with fewer dependencies.
Type::Library::Compiler allows you to create a zero-dependency compiled version of your type constraint library, which can be used by Mite.
AUTHOR
Michael G Schwern <mschwern@cpan.org>.
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2011-2014 by Michael G Schwern.
This software is copyright (c) 2022 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.