Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 11:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found