Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

You seem to be viewing (...) as a data structure. That isn't at all unreasonable, but it is not the only meaning that we commonly give to (...). Perl's definition of (...) is drawn from another part of life: math. A better mental model would be the parenthesis in math statement: (3+4)*(6+10). It is simply a way of grouping things to indicate the order in which you want them processed.

Merely being an ordered collection doesn't determine how we'll use it. There are many different things one can do with groupings: nest them, concatenate them, visit their members one by one. In Perl which action you want to take on the grouping depends entirely on context. For example, when you use it in a for loop, the for loop processes the elements in order (just as you asked). And when you assign it to an array, Perl adds each element to the array in order, just as you asked. Nesting parenthesis doesn't change the treatment any more than does ((3+4))*((6+10)). The elements still get added in the order you requested.

I had little trouble grasping Perl's approach to parenthesis because my interest in mathematics and my interest in programming are closely related. Perl's syntax was natural for me. But I fully appreciate that others have come to programming from different directions than I. They are used to giving symbols other meanings than I give them.

It all comes back to the the vagaries of DWIM (Do What I Mean). As tweetiepooh has pointed out a language's strengths are also its weaknesses. DWIM, or as Larry Wall calls it "The Principle of Least Surprise", is rather subjective:

... The question is, whose surprise are you pessimizing? Experts are surprised by different things than beginners. People who are trying to grow small programs into large programs are surprised by different things than people who design their programs large to begin with.

For instance, I think it's a violation of the Beginner's Principle of Least Surprise to make everything an object. To a beginner, a number is just a number. A string is a string. They may well be objects as far as the computer is concerned, and it's even fine for experts to treat them as objects. But premature OO is a speed bump in the novice's onramp.

Interview with Larry Wall, Slashdot, Sept, 2002

In a language where DWIM rules, we need to be very sensitive to the fact that not all of us are thinking the same thing when we get to the word "mean". If you are teaching Perl or helping an organization develop Perl skills it is very important to be sensitive to this issue or else you will end up with confused frustrated programmers for whom Perl definitely does not do what they mean.

Best, beth


In reply to Re^2: disadvantages of perl by ELISHEVA
in thread disadvantages of perl by perldesire

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (10)
    As of 2014-04-16 10:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (423 votes), past polls