Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the nextgen CPAN distribution.

Report information
The Basics
Id: 61995
Status: open
Priority: 0/
Queue: nextgen

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.05
Fixed in: (no value)



Subject: Load Moose only when necessary
nextgen always loads Moose, even when used in "main". Moose is very expensive to load. In order to make nextgen more generally applicable, it should only load Moose if it intends to use it. Because of its prohibitive load cost (despite what the Moose folks say, not everything is run persistently) and its narrow use (not everything is OO and wants to use Moose) and simple interface ('use Moose' is not much to type) I would further recommend against nextgen loading Moose at all. As a final compromise, consider Any::Moose instead which will give you Moose semantics without clobbering every nextgen user with the load cost.
nextgen doesn't load Moose into main, the main import is always 'mode' => ':procedural'. Any::Moose, and in fact Mouse and all things Mouse are hardly ever worth the trouble. They're actually quite slow. I don't think running perl in a non-persistent fashion is ever good idea. With that said, I'm inclined to reject this bug. Feel free to open it up if you want to try another argument to convince me or another solution free free to continue posting. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
On Fri Oct 08 18:01:17 2010, ECARROLL wrote: Show quoted text
> nextgen doesn't load Moose into main, the main import is always > 'mode' => ':procedural'.
I might not have been clear. nextgen.pm says "use Moose ();" which means it always loads Moose. Whether it gets imported into main is immaterial to this bug. The patch is trivial and cuts nextgen.pm load time in half. Loading mro, B::Hooks::EndOfScope and namespace::autoclean (that was the real killer) on demand saves a further half. diff --git a/lib/nextgen.pm b/lib/nextgen.pm index b02154b..2feb3be 100644 --- a/lib/nextgen.pm +++ b/lib/nextgen.pm @@ -9,7 +9,6 @@ use v5.10.1; ## Core use IO::Handle (); -use mro (); use feature (); ## CPAN procedural @@ -17,10 +16,6 @@ use autodie (); use indirect (); ## CPAN OO -use Moose (); -use B::Hooks::EndOfScope qw(on_scope_end); -use namespace::autoclean (); - use nextgen::blacklist; sub import { @@ -49,14 +44,18 @@ sub import { ## Moose will import warnings and strict by default if ( !$procedural && $pkg ne 'main' ) { + require mro; mro::set_mro( $pkg, 'c3' ); - + + require Moose; Moose->import({ 'into' => $pkg }) unless $pkg->can('meta') ; ## Cleanup if the package has a new or meta (Moose::Roles) - on_scope_end( sub { + require namespace::autoclean; + require B::Hooks::EndOfScope; + B::Hooks::EndOfScope::on_scope_end( sub { no strict qw/refs/; no warnings; namespace::autoclean->import( -cleanee => $pkg ) Show quoted text
> Any::Moose, and in fact Mouse and all things Mouse are hardly ever > worth the trouble. They're actually quite slow.
The numbers say otherwise. $ time perl -wle 'package Foo; use Moose' real 0m0.231s user 0m0.207s sys 0m0.022s $ time perl -wle 'package Foo; use Mouse' real 0m0.039s user 0m0.028s sys 0m0.008s (this is after making sure they're disk cached) The 200ms cost of Moose is imposed on every use of nextgen.pm, regardless of whether it wants to use Moose or not. You might argue Mouse's runtime is slower (I'd be very surprised and would be interested in the benchmarks) but that only matters if you actually use it. Show quoted text
> I don't think running perl in a non-persistent fashion is ever > good idea. With that said, I'm inclined to reject this bug.
...so no command line programs using nextgen?