Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

(Ovid - Perl and linguistics) Re: Perl's warts

by Ovid (Cardinal)
on Mar 21, 2001 at 23:06 UTC ( [id://66101]=note: print w/replies, xml ) Need Help??


in reply to Perl's warts

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://66101]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-26 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found