http://www.perlmonks.org?node_id=725161

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

After a script has been debugged and finished, will leaving "use warnings" and "use strict" in do anything negative in terms of memory use and time? Ie. should I take that out of the final product?

Replies are listed 'Best First'.
Re: removing "use strict" eventually
by moritz (Cardinal) on Nov 21, 2008 at 16:11 UTC
    Note that use strict also has run-time effects (the strict 'refs'; part), so removing the use strict; line might cause trouble in some conditions that you didn't come across while testing. So leave it in.

    Also note that most of the time some other module that you use uses strict, so there's no significant speed or memory gain when you remove it from your script. So don't remove it.

Re: removing "use strict" eventually
by mikelieman (Friar) on Nov 21, 2008 at 16:07 UTC
    I would leave them in the production code. Worst case, the users will report the warnings you should have fixed before release, and justify a maintenance update.
Re: removing "use strict" eventually
by JavaFan (Canon) on Nov 21, 2008 at 16:46 UTC
    Well, it will have an impact, but mostly if it actually triggers a warning/error - because then it does work.

    But it will only do extra work if there's a problem, and further more, if such tiny resource uses are important for the overall running time of your program, you shouldn't have used Perl in the first place.

    It's like after having choosen the Winnebago over the Ferrari, you wonder whether driving with side mirrors impacts its performance. (The answer to that is "Yes, side mirrors impact performance, but who cares about the difference, and wouldn't it be much better to leave them on in the first place?")

Re: removing "use strict" eventually
by ww (Archbishop) on Nov 21, 2008 at 21:09 UTC
    There's a famous observation to the general effect:
    The last bug has been eradicated when the last user stops using your program.

    Leave strict and warnings in!

    Contrariwise, in the case of a web page or ap, you probably do want to remove/comment out instructions like use CGI::Carp qw(fatalsToBrowser); because if you leave them in, you may give more help than you intended to someone trying to develop an exploit.

Re: removing "use strict" eventually
by perrin (Chancellor) on Nov 21, 2008 at 20:36 UTC
    There's very little upside to taking it out and potentially major downside when you miss runtime errors. I'd leave strict and warnings in.
Re: removing "use strict" eventually
by bart (Canon) on Nov 28, 2008 at 10:11 UTC
    There's no point in removing strict, that is mostly a compile time check anyway; and if something really goes haywire, like using a hash entry as a reference (in a complex data structure) when it has already been assigned a string value, you don't really want it to go on. Without strict, Perl would use that string as the name for a global variable... Eventually it could even do serious damage to your data in the database.

    As for warnings, that's something else. There have been numerous arguments about it, and there may be valid reasons to disable it in production code. The most important reason that suddenly warnings start to appear, is that an upgrade of Perl could make things that didn't produce a warning before, but do in the new Perl version. For a command line script, that is not so bad (on the contrary, in scripts for my own use they tend to point to irregular data), but if running on a web server, that suddenly could start to cause server errors. Ouch.

    If anything, on a web server, make sure the warnings don't produce anything that the user sees, even if it doesn't cause an error. It's no use to him. Make them go to an error log.

A reply falls below the community's threshold of quality. You may see it by logging in.