Programs are complex beasts no matter what you use to express them so the simpler do you make one thing, the more complex ends up some other.

I don't buy that. I think that Perl makes a lot of things much simpler than they would be in, let's say, C. Memory management, for example. There isn't a complexity debt to be paid. It's not zero sum.

What I meant by "Perl has too many weird pitfalls for beginners" is not obfuscation but rather things that look good to a beginner but aren't. Examples:

$x = ~ /regex/; %hash = map { "\L$_", 1 } @array;

If the poor beginner hasn't learned to Use strict and warnings,

$hash1 = { a => 1 }; $hash1{b} = 2; # $hash1{a} == 1, right? No?

I don't think the degree to which a language can be obfuscated should be a concern for beginners. A beginner reads code only from a text book that doesn't obfuscate or from their own programs which they also haven't obfuscated. The problem with Perl for a beginner is that it's possible to write code that looks as if it should work but doesn't because of some obscure historical reason or very common misunderstanding.

I saw something like this not too long ago:

foreach (@foo_list) { my $x = "blah $_ blah"; my $foo = $_; while ( something() ) { # more stuff foreach (@bar_list) { other( $_ ); } } more_with( $foo ); }

I wonder how long the programmer had to debug to figure out that $_ at the end of the loop had changed, and it ought to be saved in $foo. To you and me, "foreach my $foo (@foo_list)" is obvious, but we learned the lessons of $_ a long time ago.

See also perltrap. (We have a whole section of the documentation for "traps for the unwary"!)


In reply to Re^3: Perl as one's first programming language by kyle
in thread Perl as one's first programming language by amarquis

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.