In a message dated: Tue, 20 Aug 2002 10:45:48 EDT
"Derek D. Martin" said:

>Here are two ways to do (more or less) the same thing, one in C and
>one in Perl:
>
>   setlinebuf( file );
>   $| = 1;
>
>Which is clearer to the inexperienced reader (but experienced
>programmer)?  Which is easier to remember, for the average person?
>There is nothing to $| to attach any meaning to it...

Hmmm, if you don't like $|, as Kevin already pointed out, you can:

        Use English;

        $OUTPUT_AUTOFLUSH = 1;

which I actually find far more readable and understandable than even 
your C example above.

>Programming Perl seems to almost, but not quite recognize how painful
>these things are to learn, by offering mnemonic devicess for each of
>them.  But Perl hackers seem to favor this kind of variable, using
>them often when there's no need to.

Well, I think it's more that they're lazy.  Why type $OUTPUT_AUTOFLUSH
when you can type $| instead?  If someone who doesn't know the 
language needs to know what $| does, it's well documented.

(Personally, I always try to accompany these types with a comment 
that explains what these types of args do.  The exceptions being
$_ and $!, since they're used so often as a Perl programmer, you 
should know what those are.)

>Again, it's not about documentation.  It's about design.

Right, and perl was designed to be as flexible or as rigid as you'd 
like it to be.  I think it's more about learning the language.  I 
"know" C, but I'm not proficient at it.  I can write small programs, 
and do a little damage.  But if I were to look at code written by 
others on this list who are more proficient, I'd be lost.
The same goes for Perl.  I've been writing perl for 8+ years, which 
makes me far more proficient at it than I am in any other language.

I would say that you're quite a bit more proficient at C than I am, 
but less so at Perl.  Things like $_, $!, $|, etc. are second nature 
to me, where as things like setlinebuf are second nature to you.

The better you know a language, the less obscure it seems.  Perl 
seems very obscure to those who don't know the language just as C 
seems quite obscure to those who don't know it.

>> Example?
>
>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.

>Well, there are certainly people who like to write obscure C as well.
>It just seems to be part of the Perl culture...  I've seen far less
>readable Perl than C.  In fact, I'd say the most readable Perl I've
>seen was in Learning Perl, and some of that I thought looked kinda
>gross too.  It is as if unreadability was designed into the language.

I guess it's all perspective.  I look at the code in Learning Perl, 
and I see very clear and obvious code.
-- 

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!


_______________________________________________
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

Reply via email to