Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Learning Perl as a First (programming) language

by talexb (Canon)
on Aug 02, 2002 at 12:53 UTC ( #187073=note: print w/ replies, xml ) Need Help??


in reply to Re: Learning Perl as a First (programming) language
in thread Learning Perl as a First (programming) language

I agree with you that comp.lang.perl.misc is a bit of a junkyard. It's where programmers who have tried to force their way up the Perl learning curve can post their messes instead of buckling down and doing some reading and hard work.

But I believe Perl is easy to learn because Perl does little things for you like allow you to enter

for ( $i=0; $i<10; $i++ ) { print "$i"; }
and get it up and running in no time. Sure, you get '0123456789' as the output, but there were no include files, no compiler or linker to deal with, and no memory management or window management to worry about.

Perl is a very elegant language, but it can also be really gross (e.g., obsfucations) -- but that's OK, at least it's flexible. I programmed in Pascal for a while and wasn't really thrilled every time I had to cast a char to an integer in order to do some math with it, then cast it back to a char. Ugh. Or deal with the nervous nelly compiler errors.

I really can't imagine starting with Java -- it's not my idea of a lightweight language. I find it rather dense, and I spent many years programming in C. Even starting with an OO language is a bit of a jump -- I expect that people want to jump right in and start trying things. Writing clean, Object Oriented code can come later.

I don't think Perl has a bad name -- it has a pretty good reputation. Sure, it may be hard to learn, but then :) I'll take that any day over something as trivial as Pascal.

--t. alex

"Mud, mud, glorious mud. Nothing quite like it for cooling the blood!"
--Michael Flanders and Donald Swann


Comment on Re: Re: Learning Perl as a First (programming) language
Download Code
Re: Learning Perl as a First (programming) language
by Abigail-II (Bishop) on Aug 02, 2002 at 13:30 UTC
    I'm not impressed by your example of doing little things. Even in C (which I don't recommend as a first language), it's easy to do - in fact, it translates almost token for token. It's like saying a Ferrari is a good car to learn driving with because it's easy to turn on the headlights.

    You say that Java isn't your idea of a lightweight language. I don't disagree with that, but hopefully you aren't suggesting that Perl is. Perl is far from being lightweight language, in all aspects. It has a syntax hardly anyone, including wizards with more than five years of experience, can fully remember, and it has a very wide range of primitives. I doubt there's a language with a significant user base out there that has such a complex function to open a file. It was only yesterday that on perlmonks people were confused about 1-arg open.

    Abigail

      Since you asked, here's the equivalent in C (for those that aren't familiar -- I'm sure you are):
      #include <stdio.h> int main(void) { int i; for ( i = 0; i < 10; i++ ) { printf ( "%d", i ); } }
      The equivalent in Perl is
      for ( $i = 0; $i < 10; $i++ ) { print $i; }
      No variable declarations, a friendlier print statement, and no mysterious 'cargo-cult' include thingy.

      Don't get me wrong -- I have programmed in C since the early 80's and I love the language. But Perl takes care of lots of the underlying stuff (how many times did I write fopen(), fread() and fclose() statements I wonder). That's why I think Perl is a better choice than C.

      Perl can be a heavyweight language, but it can also be lightweight. To use the car analogy, C is a bit like the British Triumph, a little finicky, but piles of power and cornering. Pascal is a bit like a Pinto or a CV5 stuck in second gear. Perl is like a Porsche or a Lexus, nimble yet powerful.

      --t. alex

      "Mud, mud, glorious mud. Nothing quite like it for cooling the blood!"
      --Michael Flanders and Donald Swann

        Well, you are forgetting a my $i if you want to have equivalent code. I maintain the code is nearly identical - there's a few lines more in C, which look a lot for such a short program, but it wasn't linear in the size of the Perl program. Had you have had 100 of such loops, you'd have had the same amount of extra lines.

        I never claimed that C would have been a better choice than Perl. Instead, I said that I didn't consider C a good first language either. IMO there's only one reason to learn C before learning Perl and that's because there's so much of C in Perl. It makes you a better Perl programmer.

        Abigail

        Perl is like a Porsche or a Lexus, nimble yet powerful.

        I rather think Perl is more like a little Z3 that'll turn into a cement mixer, eigtheen wheeler, station wagon (complete with wood panel sides), tow truck, fire engine, or lear jet with the push of a button.

        Ok. . . with the push of many buttons in exactly the right order. . . or close to the right order anyway.

        -sauoq
        "My two cents aren't worth a dime.";
        
Re: Re: Re: Learning Perl as a First (programming) language
by Anonymous Monk on Aug 03, 2002 at 13:52 UTC
    If you are going to explain how Perl lets you learn, why don't you show that in the form that beginning programmers should learn?
    for my $i (0..9) { print $i; }
    Less mechanics to remember, and no possible confusion over off by one errors. Or even in this case (depending on which way the example was going to develop) just:
    print 0..9;
    Either of these is more convincing than writing Perl like a C refugee.
      The point that is appears you missed, my dear Watson :), is that I was debating similarities between C and Perl with Abigail-II. I was not trying to out-golf anyone on a zero to nine loop.

      Particularly :) Abigail.

      --t. alex

      "Mud, mud, glorious mud. Nothing quite like it for cooling the blood!"
      --Michael Flanders and Donald Swann

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-07-29 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (217 votes), past polls