in reply to Modules that do Less

I do agree that modules sometimes grow larger than is healthy for them. There's always the temptation to add that one additional feature-- it'd be cool, and wouldn't hurt anything, one thinks to oneself. Following this path, one can end up with a module so bloated it's difficult to understand. A module should do one thing and do it well.

Even so, I think that CGI doesn't fall into that category. Even if it has some features that you don't use, these functions aren't hurting you because until you use them they're not even compiled. From Lincoln Stein's web site:

Ordinarily autoloads most of its functions on an as-needed basis. This speeds up the loading time by deferring the compilation phase.

In other words, there's rarely any reason to worry about loading It loads in only the parts that you use.


Replies are listed 'Best First'.
Re: Re: Modules that do Less
by dragonchild (Archbishop) on Jun 12, 2001 at 19:13 UTC
    Having not read the code for, I'm wondering how this is done. Is this a Perl feature or do you have to do a huge amount of contortions to get this to happen?
      A bit of both. CGI goes through huge contortions to do its version of autoloading, because Lincoln Stein is a very clever man who wanted to do things his way. However, using the SelfLoader is pretty simple; you put your functions after a '__DATA__' token and say 'use SelfLoader' at the top. The AutoLoader module is a bit more complicated, but can offer better results.


Re: Re: Modules that do Less
by AidanLee (Chaplain) on Jun 12, 2001 at 18:50 UTC
    Thanks, I hadn't visited his web site. This was exactly what I was wondering.