<pulpit>

Well, time for me to join in the chorus of those disliking this article. One of the things that I have said, many times, is that the strongest criticisms of Perl usually come from those who do not understand Perl well. In fact, I'll go so far as to say that even those who generally do know Perl well get caught up on one thing: they fail to appreciate the linguistic nature of many Perl statements.

Case in point. The author complains about the following snippet:

foreach (1..10) { print }
His argument is that for the average programmer, it doesn't appear to do anything. Well, that's true for programmers who don't appreciate the linguistic nature of Perl. Think about what happens when someone says "pick up an apple and eat it." What is "it"? We (humans) understand that "it" refers to the apple. A non-thinking computer needs to be told something that's the equivalent of "pick up the apple and eat the apple."

The computer typically cannot infer then meaning of "it". Perl, on the other hand, can. "It" is analogous to $_. In this case, of course, the $_ is implied, but the point holds (I think). There are many examples in Perl of things like this. Understanding context is another one.

$var = @array; ($var) = @array;
The two lines above are a great example of context. The answer to your question depends upon how you ask it. It's the same with language. If I ask someone "Are you going to the store?", it can have different meanings depending upon the context (in this case, the emphasis). For example, if I emphasize the word "you", I'm asking if it is you who is going to the store. If I emphasize the word "store", I am asking where you are going. Those are totally different questions, yet the words are the same.

I think this is one of the biggest stumbling blocks for new Perl programmers. Until they grasp that Perl, at one level, is fundamentally different in approach from other languages, they'll have problems and that is a huge reason why so many people whine about Perl. Perl, once you grok it, tries really hard to work the way we think, rather than the way computers think.

</pulpit>

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid - Perl and linguistics) Re: Perl's warts by Ovid
in thread Perl's warts by grinder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.