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] |
Hi there,
I don't think I am getting power away from über-users when I say I prefer strict and warnings on by default for Perl 6. Nor I think I am leaning towards the newbie camp too much. Perl is a complex language with a steep learning curve at first, specially considering they are teaching Java in the schools now, which distorts their minds into a particularly narrow viewpoint of programming and designing. If everybody say strict should be used, and man perl itself considers warning off by default a Perl bug, I'd say it's simply putting explicitely what many newbies (and not so newbies, either) learn the hard way over the time.
If we free their minds from those troubles from the start they can pursue better things like mastering the rest of the language, which is a feat by itself.
We all have seen (and many written) code like this before:
use strict;
...
for my $fun ( @funs )
{
no strict 'refs';
*{__PACKAGE__::"$fun"} = sub { blah blah blah }
}
... or similar code. We would be just getting rid of two explicit declarations that many people forget to write in their programs. Maybe the explicit telling of them is a good exercise of thoughtfulness and responsibility by itself, I wouldn't disagree to that, but we know from experience that many Perl programmers do not raise to the challenge, and this creates a distrusting fame around the language that affects negatively to all programmers, good and not.
Considering that some people do work using Perl, we don't need to keep feeding the suits with distorted views of the reliability and power of Perl to make a project; enough hype surrounds them from other camps.
I am just trying to be pragmatic and practical...
Best regards,
-- our $Perl6 is Fantastic; | [reply] [d/l] [select] |