(jeffa) Re: Requiring use strict
by jeffa (Bishop) on Jul 15, 2003 at 22:36 UTC
|
The only analogy i can think of (today is analogy day, by
the way) is that when vehicle
seatbelts were first introduced, they were not mandatory.
As the pusher robot pointed out, it's important to retain
some kind of backwards compatability, and when Perl was
first introduced, there was no strict.
As an aside, check out 'use strict' is not Perl ... it's a good read.
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
| [reply] |
Re: Requiring use strict
by runrig (Abbot) on Jul 15, 2003 at 22:26 UTC
|
Has there been any discussion on making the strict pragma mandatory?
A related note is under the BUGS section of the perl manpage:
BUGS
The -w switch is not mandatory.
The same might be said for strict.
The answer, though, is that it just gets in the way for simple-under 10 line type scripts, and perl is equally good at short scripts and long programs. And depending on the needs of your program (i.e. if you are TheDamian), it might even get in the way on longer things. | [reply] [d/l] |
|
|
| [reply] |
Re: Requiring use strict
by jonnyfolk (Vicar) on Jul 15, 2003 at 22:26 UTC
|
The benefits of using strict are humungeous and it is really well worth doing.
So what to do? Simply type in use strict at the top of your script and wait to get hammered! A couple of hours with a metaphoric sharp pencil should see things well on the way to getting sorted and if you have any residual problems then a further request from this site will see an enthusiastic response, I'm sure.
The bottom line is if it's your script, and you want strict use strict; !
| [reply] [d/l] [select] |
Re: Requiring use strict
by the pusher robot (Monk) on Jul 15, 2003 at 22:25 UTC
|
The only real issue with making strict mandatory (and having 'use lenient' instead?) is that it'll break current programs, which is not something to be done lightly. I suppose 'strict' could be the default for Perl 6 (at least when not running in Perl 5 compat. mode), but I don't believe that's being done. | [reply] |
|
|
| [reply] [d/l] |
Re: Requiring use strict
by tcf22 (Priest) on Jul 16, 2003 at 02:29 UTC
|
In the first Perl book I read, one of the first things that was said when describing the language, was that it was a language without unnecessary restrictions, but that it wasn't always a good thing.
Even though using strict is definitely a must, I think it would actually go against the original idea of Perl, if it was forced upon you. There must at least be an option.
However, I think that something like use lenient, would probably have been a better choice, because you would have to explicitly choose to write bad code. But its a little hard to change now, without breaking a whole lot of old code. | [reply] [d/l] [select] |
|
|
That old code would be pretty easy to fix, if it only needs an 'use lenient;' option...
I never used strict when I started with perl (it made my code fail with a zillion error messages, quite depressing), until someone on this forum pointed out the benefits. I had to bite the bullet, I moved all my little scripts and cgi's over, and it has thought me to write much better perl code.
I don't exactly remember how long it took to switch, but I vividly remember how shocked I was about the number of bugs and typo's found. Unless you (OP) really, really know what you are doing and can give yourself a very good explanation of why using strict would only harm your program, you are probably better off to faithfully start writing your perl with strict, warnings and tainted.
Without strict, your code only looks as if it works. With strict, you get a very good indication that your code really does work (barring any logical errors or wrong conceptual ideas in your code ofcourse). As Jeffa said, use the seatbelt. Maybe it sets you back in a small number of cases (in some freak accidents people die because they were wearing a seatbelt, I've read), but there's no way you can balance it with the number of times it saves you. No matter how good you are; 4 o'clock at night and lack of caffeine is lethal to anybody's concentration and thus code.
So I like the idea of a default 'use strict;', so people who start with perl don't get the wrong idea about it being a frivolous extra like I did at first. 'use sloppy_programming;' should be an option, not the default.
Feel free to disagree, ofcourse.
| [reply] |
|
|
I'm also wondering if it would be a good idea to use strict during development and testing and not to use it once the code has been proven to work, to increase speed. And I'm wondering if it would be feasible to write a compiler/module to convert non-strict to strict and strict to non-strict.
The Wonderer
| [reply] [d/l] |
|
|
Hi there,
I think making the use warnings and use strict a default for Perl 6 would be a generally good idea.
Code that doesn't need them can always say "no strict; no warnings" (no need for a "lenient" pragma) and a couple of handy command line switches like -w (for "no warnings", reuse is good, people get used after a while, after all) and -f (not in use, for "no strict"; f from "fool the strictness of the compiler", if not a blatant "i want to be a fool") would do for one-liners.
Power is good. Raw power in the hands of newbies or incompetent is a shotgun aiming at their feet. Considering everybody in the higher spheres recommends always using strict and warnings, this is a logical step to pursue. If you know what you are doing (TheDamian et al.) you can turn it off the same way they do it nowadays, but instead of inside a little { block } to mangle with the symbols table, for the whole program/package if they want: it's there, they use it when they know they can. The newbies will just have to wait until they know better, which is a Good Thing, IMHO.
Best regards,
-- our $Perl6 is Fantastic;
| [reply] [d/l] [select] |
|
|
While I'm not going to argue your wish that perl6 should
have 'use strict' as a default, I do question your reasoning.
I do not think it's right for a mature language to suddenly
start catering towards newbies. Languages aren't judged on
their newbie friendniness. Otherwise, COBOL and Pascal would
be much more appriciated then they are now.
It's a mistake to think that what's good for the newbie is
good for the advanced user as well. Bikes don't have trainingwheels
as a standard feature. The standard edition of a novel
isn't one with big letters and words with few syllables.
Features for newbies are good, but the main design of a
language should always cater advanced users. Being a newbie
is (hopefully) something people don't stay too long. The
goal is that they are an advanced user for much longer that
they were a newbie.
Abigail
| [reply] |
|
|
Re: Requiring use strict
by Anonymous Monk on Jul 16, 2003 at 00:59 UTC
|
Why blame the language. Why not simply blame the coder. After enforcing use strict; we'll need to use explicit casts for scalar and list contexts. Next we'll be killing all of those handy little variables that are everywhere. Finally, Perl will be made strongly typed. Its a funny thing, of all the languages I use (C,C++,Java,C#,VB), Perl is the only one that I experience as different. Thats why I use Perl whenever I can. Its like the only fun programming language that I can find an excuse to use.
Am I the only one whose is tired of hearing "good programming practice." Go read up on the Sun Java and MS .net crap for a few days -- "we are going to make your coding robots more productive by building good programming practice principles into the system from the ground up." Yeah, ok. I still think that if C had a native string type, or a reasonable string library, we could all have been spared all the pain of C++ and Java.
So, dont want to "use strict;" explicitly
use the C/C++/Java/C# programming language
| [reply] |
|
|
Yes, sometimes I'm tired of hearing "good programming practice" as well. Usually up until the moment where I have to open up an old script from mine again (or even a script from someone else), and feel like wading through thick undergrowth when reading the code. I know use strict doesn't help there, but "good programming practice" does.
I can see your point about "good programming practice" being shoved down your throat. Perl, as runrig pointed out before, is good for small and big things - and I hardly ever use strict when all I do is write a wee 5-line script. Same goes for what you call "fun programming".
To use jeffa's seatbelt-analogy again, seatbelts restrict you in your freedom, may even make you feel trapped if you're not used to them. But boy would I feel good if I didn't fly through the windscreen in an accident...
--cs
There are nights when the wolves are silent and only the moon howls. - George Carlin
| [reply] [d/l] [select] |
Mandatory Strictness
by jdklueber (Beadle) on Jul 16, 2003 at 18:43 UTC
|
Hi. My name is Jason Klueber, and I use strict;.
Hi, Jason!
Anyway, I see a good reason to not make strictness the default:
perl -e
If strictness is a default, then oneliners become more cumbersome, and therefore less useful. (The entire point of a oneliner being to Just Do It.) Since oneliners are one of the reasons perl is what it is, I don't support crippling them just because we're tired of telling people to "use strict or die;". :)
Oh. And mandatory strictness breaks all my japhs. ;-)
--
Jason Klueber
ookami@insightbb.com
/(bb)|^b{2}/
--Shakespeare
| [reply] |
Re: Requiring use strict
by Anonymous Monk on Jul 16, 2003 at 10:21 UTC
|
i agree with schumi; fine, use strict if you like; most often i do; but excessive preaching about it's virtues, and requiring me to use it all the time, goes against (my view of ) perl's grain: TIMTOWTDI. in other words; allow me to make my own decisions about using strict, i am perfectly capable of doing so. even if i am anonymous.
yours feistily. | [reply] |