in reply to Re: Perl as one's first programming language
in thread Perl as one's first programming language

(!= (s(i(m)(p))(l(e)))((e(a s)y)))

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. In this particular case you end up with Lots of Irritating Silly Parenthesis. And searching for that one misplaced character out of thousands exactly the same characters can be very frustrating.

Replies are listed 'Best First'.
Re^3: Perl as one's first programming language
by kyle (Abbot) on Apr 08, 2008 at 14:59 UTC

    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"!)