practicalness of “use strict;â€

X

Xah Lee

i've been coding Perl since 1998. I've always followed the “use
strict;†rule. However, in recent years i started to get loose by
purpose and thinking perhaps it is not that necessary. I haven't really
written large scale code without it (i.e. in a company setting), so i
don't really know if it's gonna sting in debugging.

my question is, for any of you who have experience in both using strict
and without: does it actually matters?

Xah
(e-mail address removed)
∑ http://xahlee.org/
 
D

Dave

i've been coding Perl since 1998. I've always followed the "use
strict;" rule. However, in recent years i started to get loose by
purpose and thinking perhaps it is not that necessary. I haven't really
written large scale code without it (i.e. in a company setting), so i
don't really know if it's gonna sting in debugging.

my question is, for any of you who have experience in both using strict
and without: does it actually matters?

Xah
(e-mail address removed)
? http://xahlee.org/

The rule of thumb is that it is OK to turn strictures off if you know why
you are doing it; just turn off the minimum necessary for the minimum scope
necessary.
i.e. you don't turn it off completely, but you might have:
no strict 'refs';
in a subroutine where you are using symbolic references, provided you know
why you are using them rather than one of the cleaner ways of acheiving the
same result that may be available.

One of the risks of turning them off is that you produce less maintainable
code.
 
T

Tim Shoppa

my question is, for any of you who have experience
in both using strict and without: does it actually
matters?

There certainly are some very useful things you can do with warnings
off that you cannot do with warnings turned on.

If you're doing something moderately funky with do-it-yourself
autoloading and on-the-fly function generation you often do a "no
strict 'refs'". Good style is to turn this off only for the block
where you need it.

Tim.
 
U

usenet

Xah said:
my question is, for any of you who have experience in both using strict
and without: does it actually matters?

I started writing Perl programs six years ago, after earlier experience
programming in languages where I actually had to pre-declare every
variable (and stipulate what type of variable it was- integer, boolean,
etc). I enjoyed the "freedom" that Perl gave me, and initially I never
used strict. The notion that I make up a variable "on the fly" which
could serve as an integer or a string was "liberating."

I wrote some pretty big (and ugly, in retrospect) programs that are
still in production use today - this code would probably curl Larry's
toes, but it works (and without strict).

In the past couple of years, though, I have adpoted much more rigerous
standards for myself and always code with strict (turning it off - in
minimal scope - only when I really understand WHY I'm turning it off).
I have found that it greatly helps me save debugging time.

Oh, and when I started using mod_perl for web apps, 'strict' (and a
proper understanding of lexical scoping) became MUCH more important.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,946
Members
47,497
Latest member
PilarLumpk

Latest Threads

Top