Perl
pll at lanminds.com
pll at lanminds.com
Tue Aug 20 14:03:56 EDT 2002
In a message dated: Tue, 20 Aug 2002 12:34:47 EDT
"Derek D. Martin" said:
>But the point is that there is no meaning inherent in $!
>(the use of which BTW, I have no idea, despite having seen and I'm
>pretty sure even used)...
Actually, there is. The meaning of $! is "what just blew up". I.e.,
when something blows up, it goes 'bang'. This variable tells you
that.
>This, in combination with the fact that there are dozens of these variables,
>in combination with the fact that most Perl programmers seem to be delighted
>to use $a and $b, makes it very difficult to remember what they all do, and
>read code that uses them.
$a and $b are not chosen at random. They are very specifically
chosen because they are used by perl's sort().
>Even were I to use Perl regularly, I would have a hard time
>remembering which was which, and hence avoid them whenever possible.
>They do not lend themselves to being learned, and I've never been good
>at memorizing.
I disagree. The more you use something the better you know it.
There is a huge diffence between "knowing" and "memorizing".
In general, the human brain is not good at memorizing, and it's
generally accepted with in those who study "how the brain works" that
memorization is the least effective way to teach something.
Knowing something is entirely different. Ultimately, I feel that
it's useless to know what all the "magic" variables in perl do off
the top of my head. If I need to use one, I read the docs to figure
out which one I need and make a comment in my code saying what I did.
I don't have them all memorized, and I doubt most perl programmers do
either. There are maybe 3 or 4 which are used with any sort of
regularity. No, it may not make the code overly readable to those
who don't know the language, but to those who do, it's as clear as it
can be.
You're complaints seem to stem more from the fact that you don't know
the language proficiently than anything else.
>> >Structures come to mind, though they're not as bad as some things I've
>> >come across (can't recall what though). I thought I already gave
>> >that, but I guess I didn't.
>>
>> Perl doesn't have structures, it has hashes. Different concept.
>> They can be used to emulate a structure, but they are not structures.
>
>Precisely.
>
>Programming languages manipulate data, very often involving multiple
>types of information; data structures. This is a fundamental part of
>programming, so much so that it's taught to all first year CS
>students. Perl makes manipulating data structures harder than it
>needs to be. IMO, this is a weakness of Perl.
But Perl is meant to manipulate TEXT, therefore, why should it need
structures? There are inherently only 3 data types in perl: scalars,
arrays of scalars, and hashes of scalars. That's a very different
paradigm than other "traditional" languages. It's not a weakness,
it's a strength, it just happens to be one you're not accustomed to.
>I'm not saying Perl is a bad language. I am merely saying that I
>found/find it reletively difficult to learn, for reasons I've stated,
>and can definitely see why others balk at the prospect. Or said
>another way:
>
>I like perl. It makes shell scripting easier. =8^)
That's only because you're looking at it wrong. Perl is a language
meant to manipulate text. It's not C and it's not shell. It does
have facets of both, but it is a replacement for neither one.
There are problems Perl is very good at solving, and there are
problems which perl *can* solve, but would probably be better off
written in C, python, lisp, or even sh.
The problem I think you're having is that you think in C, know
shell very well, and attempt to make too many parallels with those
two languages.
Perl is not a hard language to learn the basics of, and one can
easily write very complicated perl programs in a very straitforward
and readable manner without ever touching the "magic" variables.
It just so happens that those who know the language choose to use them
because it's shorter. It's the same with the '?:' construct in C.
That is not even close to readable unless you know the language, but
yet people persist in using it despite the fact that it offers no
more functionality than a simple if...then construct.
--
Seeya,
Paul
--
It may look like I'm just sitting here doing nothing,
but I'm really actively waiting for all my problems to go away.
If you're not having fun, you're not doing it right!
More information about the gnhlug-discuss
mailing list