[Israel.pm] use and require

sawyer x xsawyerx at gmail.com
Sun Mar 20 01:14:27 PDT 2011

On Sun, Mar 20, 2011 at 9:54 AM, David Baird <davidlbaird at gmail.com> wrote:

> IMHO, a nice change to Perl would be to defer loading class modules
> until the first Class::Module->new() statement is encountered, and at
> that point, Perl would "require" but not "import" the module. This is
> sufficient for most class modules, and would save time on initial
> loading of a script.

I would be very much against it. You sometimes *want* to load everything in
compile time. When I have a long running process in which the start time
doesn't matter (Gabor gave web applications as a good example), I want as
much stuff to be loaded beforehand (assuming of course I didn't use insane
memory-consuming modules, and have a correct server configuration) than to
start loading a module when a user tries to login, for example.

I actually agree with both Gabor and Shmuel on this issue. Shmuel raises the
point that you should be careful of your use of "require". Many programmers
sprinkle "require" statements all over without understand how it works (hey,
no import!) and without trying to utilize the correct form of it. Gabor, on
the other hand, says that some applications *really* do need to use
"require" (heh.. "use require") whenever possible, and that's true too.

I say, as long as you know *why* you're using it and you're using it
*wisely*, it's perfectly fine, and sometimes desired.

tl;dr: have a good day. :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20110320/78630c24/attachment.htm 

More information about the Perl mailing list