I was talking to two friends of mine (one a CS student, the other a sysadmin), and I was spouting off about how great Perl is. They told me that Perl is a bad language to start in and that I would regret it later. They said that, "when you program in Perl, you don't actually *see* what is going on." Apparently, Perl is too forgiving if you screw up.

What do you guys think about this? I am happy learning Perl as my first language, but I am also wondering if their points are valid.

Replies are listed 'Best First'.
(jcwren) RE: Disadvantages of Perl?
by jcwren (Prior) on Jun 13, 2000 at 19:04 UTC
    Contrary to some peoples beliefs, there is no "wrong" first language. The only time a first language is "wrong" is when it's chosen to accomplish a task that it isn't suitable for. For instance, if you're going to be writing Linux kernel code, Perl *is* the wrong choice.

    For decades, there have been people who say "Oh if you learn that language first, you'll never be able to write decent code for the rest of your life." BASIC was one of the earlier culprits of that thinking. BASIC, like most languages, has it's time and place. Under Windows, for example, you can prototype a GUI faster in Visual Basic than Perl/TK, and it will look more like a Windows application.

    Different languages have different strengths and weaknesses. One of the skills you should have as a programmer is knowing several language, and know which one to use when. Perl is an excellent general purpose langage, and especially strong in text processing. Forth, on the other hand, has none of the intrinsic string handling that Perl has, but it's a lot smaller and faster (complete Forth interpeters WITH editors have been done in 4K of memory). 'C' is more suitable for operating system work, and assembly is the tool for when you really need get down to the bare metal.

    Learn Perl, but not only Perl. Learn 'C', Java, and a few others. Know when to use them, and don't become emotionally attached to a language. Learn how to implement common algorithms in all the languages you learn. Often you'll see how to write better code in one language by playing with another.

    Perl can let you develop sloppy habits. So can every other language. As I like to say periodically "You can write Fortran in any language". Don't condemn languages you haven't used (except for COBOL...). They were all developed for a reason, and have all certain strengths. Don't sneer at Visual Basic because it's BASIC. More interactive production applications ship in VB than in Perl (Perl is not really good for writing word processors and spreadsheets).

    I think you see the point I'm driving at. Perl is as good a first language as any. It will allow you to rapidly express your concepts, there's a huge base of user written modules, and there's a lot of information available (witness perlmonks.org. Tried to find COBOLmonks.org lately?) But it's not the only language, and it's not always the right language.

    --Chris
      "Learn Perl, but not only Perl. Learn 'C', Java, and a few others. Know when to use them, and don't become emotionally attached to a language. Learn how to implement common algorithms in all the languages you learn. Often you'll see how to write better code in one language by playing with another. "

      Pure Genius... When you get more mature. Learn SQL too and how to Normalize databases. Get into OO concepts.

        Very Good Points. I want to emphasize learning algorithms. Computer languages are tools and only tools. Perl is not the best choice or every application, but I've learned that it makes a great prototyping tool if I need develop an idea. Don't listen to language or Operating System bigots. They are giving out opinions, not facts. Best of Luck with Perl. "Let us go then, you and I. With the earth stretched out beneath the sky, like a patient etherized upon a table..." T.S. Eliot, The Love Song of J. Alfred Prufrock
      I think that you make some very good points here, jcwren. The is a purpose for every language. I think that maybe thew key issue here is that the language adapts to your skill. What I mean by this is that if I become very, very good at Perl, I will be able to push Perl to do anything (aside from writing a bootloader or something) I want it to. I can definitely see this quality in Perl.

      Another good point that you had was about the ability to make mistakes in other languages. I suppose one just has to be concious about what is going on behind the scenes if one is using a certain method or practice that has any significant impact on the program.

      redmist
RE: Disadvantages of Perl?
by Ovid (Cardinal) on Jun 13, 2000 at 20:36 UTC
    Here's a short, but interesting article on perl.com about Perl as a first language.

    Perl can be a great first language to learn if you're not prone to the "you have a hammer and everything looks like a nail" trap. I have a friend of mine who's a brilliant sysadmin and a Perl guru who is not overly familiar with other programming languages. As far as he is concerned, the entire Web should be HTML3.2 and Perl. He is a Perl Zealot and this is a Bad thing.

    I'm not suggesting that you face the same fate, but be forewarned that the advice that jcwren gave about learning other languages is more than just a good idea. If you don't, you only have a hammer in your toolbox. Forget the wrench, the pliers, or any other tool that's useful. Need to get that nut off that bolt? Hand me the hammer.

    That being said, another reason I would suggest learning other languages is to appreciate what Perl offers. I've worked in a whole grab bag of different languages, some of them being so obscure I doubt most have heard of them (no, I'm not some computer God, I've just been tossed from project to project). None of those languages allowed me the syntax flexibility of Perl. Most of them didn't offer concepts like regexes, hashes, or $_. But then, they're often designed for different purposes for which the aforementioned tools may not be appropriate (though I think regex should be in virtually every language).

    As for your two friends, I am curious as to how well they know Perl in comparison to other languages. I don't think you'll regret Perl as a first language, but you should regret it if it's your only language.

    Update: I was thinking about when I first was learning VB (forgive me) and I was so excited about how easy it was to create GUI apps for Windows. Now, I look back and realize that I was actually so excited about being able to create a bug. (bah dum bumm, <cymbal|symbol crash>)

    Hmmm... guess that last comment would be my entry into the obfuscated humor contest.

      You make a good point with the hammer analogy. Thanks fer the link.
RE: Disadvantages of Perl?
by le (Friar) on Jun 13, 2000 at 14:00 UTC
    Perl was the "first" language I learned, and I never regretted it. Ok, I don't hack C/C++ programs, but in my believe, Perl is a very good language if you want to learn programming. (With the guiding light of the Llama book, of course.) The fact that Perl is "too forgiving" is a grace and not a burden IMHO. I even heard, that some say Perl could be the cure of many Buffer Overflow vulnerabilites, cause Perl handles everything itself, you don't have to predeclare things. The statement that Perl doesn't let you see what's going on behind the scenes may be right, but: if you have a hammer and punch that nail in, do you need to have a grade in Physics?
RE: Disadvantages of Perl?
by Odud (Pilgrim) on Jun 13, 2000 at 14:00 UTC
    I'm not sure that at anything above the level of machine code you see anything with other languages either. Perhaps they don't like it that a scalar can be anything. Perhaps the idea of list context v. scalar context scares them. In my humble opinion Perl lets you get on with the programming/thinking by hiding the detail - you can look under the hood later if you want to or need to, but you don't have to.
RE: Disadvantages of Perl?
by turnstep (Parson) on Jun 13, 2000 at 14:32 UTC

    Well, they kind of have a point, but Perl is certainly a fine *first* language. The more languages you know, the stronger your skills will be in all of them. Having a C background, in particular, will make you a better perl programmer. C is more "low-level" and forces you to worry about things (e.g. pointers and memory allocation) that perl takes care of "behind the scenes." Once you have learned about such things, you gain a greater appreciation for all that perl really does, and how it makes it look easy while doing so :). Perl is great because you can make it as simple or as complex as you want. You can write good, working programs with a few simple keywords and concepts, yet you can still dive in deeper and deeper by eventually learning about modules, references, typeglobs, embedding perl in C (and C in perl), and eventually reading perlguts for pleasure and checking out the regex engine. :)

RE: Disadvantages of Perl?
by jjhorner (Hermit) on Jun 13, 2000 at 15:49 UTC

    I think Perl is great. When I try to code C, lately, I find myself wishing for a garbage collection routine.

    From a system admin point of view, I don't want to have to worry about compiling. I want a script that works quickly to save me a headache. If I want something more complex, perl can "scale" to that end of the spectrum. As the old saying goes: Perl makes easy things easier and impossible tasks possible.

    Don't let code bigotry affect you. People have their favorites, and you will too. If you are going to be a philosophical programmer, you will be interested in the inner workings, but if you are going to be a practical programmer, you will be interested in making your code work.

    J. J. Horner
    Linux, Perl, Apache, Stronghold, Unix
    jhorner@knoxlug.org http://www.knoxlug.org/
    
RE: Disadvantages of Perl?
by t0mas (Priest) on Jun 13, 2000 at 14:39 UTC
    I think *seeing* what is going on is a question of programming style rather than one of language choise.
    In this respect, Perl is a good language to start with, because you can start with simple and clear syntax and advance to more obscure and more efficient later.
    Most languages doesn't let you do that. You start with a complex syntax and you end with a complex syntax - that's all they offer.


    /brother t0mas
RE: Disadvantages of Perl?
by chromatic (Archbishop) on Jun 14, 2000 at 04:14 UTC
    The more you know about programming, the better programmere you'll be -- provided you have good habits.

    Perl doesn't enforce good habits on you unless you ask it to (-w, use strict), but most of the Perl gurus certainly do.

    If you want to understand what's going on, get in the habit of reading good code. Check out CPAN modules, try to come up with your own solutions to posted questions, read about algorithms and do take some time to explore a few other languages here and there.

    Once you see the same thing implemented three or four different ways (in different languages and by different people), the essentials will start to stick out, and you'll begin really understanding it.

    Perl's a great language for beginners, because it's expressive, forgiving, powerful, and very scalable. You can do just about anything with it (though there are plenty of things you probably shouldn't), and you get the results back very quickly.

    My advice is to keep learning Perl, but be prepared to branch off into other things if you want to be a serious programmer. The more tools you have in your belt, the better your solutions and the more problems you can handle.

RE: Disadvantages of Perl?
by JanneVee (Friar) on Jun 13, 2000 at 16:20 UTC
    Well you don't get to see all the innerworkings. But being a practical person I must recomend Perl to start with. The point of doing programs are to make them work. My standpoint has always been C and C++ are good for designing complex things. But before that you have to get knowledge into to your mind. Learn things. i.e. One must crawl before when one can walk.

    My point: If you really want to see what is going on under the hood learn to program Assembler. And what too forgiving when you screw up. No it's not!

    Didn't come with on the first version of this message for some unknown reason:
    When One starts with programming I think it is important to see results fast because you get tired fast if you don't get to see the end result. IMHO. Learning to program isn't about learning what is "under the hood". It is about to get the computer what you want it to do!

RE: Disadvantages of Perl?
by aedificum (Sexton) on Jun 13, 2000 at 20:00 UTC
    I am a computer science student and just started learning Perl this summer. It seems to me ( from a novice point of view ) that the only programmer that can *see* what's going on is the assembler programmer with plenty of experience on whatever system they are programming on. I really doubt whether that CS student can *see* what is going on under the hood of his C++ compiler any more than you or I can see what is going on behind the scenes of Perl. there are no disadvantages to commonly accepted programming languages as long as you use them for what they were designed for. It all comes down to the right tool for the right job. The problem you are attacking is simply to learn how to program. Is there a better way to do that than with Perl that teaches you to *see* what is really going on? Who cares. As long as you can learn the basics you will be able to apply them in other languages. Nobody *sees* everything that is going on when they are just learning how to program. I have been learning for two and a half years now and I still don't think I can *see* what is going on like I am some kind of human pentium.
RE: Disadvantages of Perl?
by el-moe (Scribe) on Jun 14, 2000 at 01:03 UTC
    A different take:

    I speak English as my first language. Some might say it's too flexable when they're attempting to learn. Others may point out the strange spelling exceptions and scoff. But I have no problem speaking and communicating with other English speakers.

    I have a few friends that grew up speaking Spanish. They speak Spanish *and* English. I have other friends that spoke German at home and English at school.

    Ok I''m rambling... let me get to my point.

    It doesn't matter what language you begin with. The first language will be your native tongue... the others will be enhancments to your repitoir. I prefer Perl to other languages because it's just so cool to code *Perlish* things. It is flexable. There may be too much documentation for a beginner. But with a little perseverance you will realize flexability and forgivness are *features* of the language.

    Did I make my point? I just want to impart to you that Perl is a fine language to start with. Don't fear the flexability... it's there to help.

    El Moe
      No your not rambling. My native tongue was Finnish. I live in Sweden and speak Swedish fluently.

      And as for my English. Well judge me by my writings if I'm any good.

      As for computer languages. In order that I learned them.

      1. Basic
      2. Pascal
      3. C
      4. Visual Basic
      5. C++
      6. Java
      7. Perl
      8. Assembler
      9. COBOL
      All my previous knowledge shows when I programme something. As for the languages I have learned. Some of these languages I actually not a good at. But as for my alltime favorite. Perl of course.

      When it comes to programming languages I'm a Jack-of-all-trades. -> master-of-none. But also this. I wouldn't have continued with it if no enjoyment was there. The only risk you take IMHO is picking a booring language for a first programming language.

      Disadvantages to PERL? The addictiveness... The beatings will continue until morale raises.
RE: Disadvantages of Perl?
by Greener (Sexton) on Jun 13, 2000 at 20:13 UTC
    I learnt C before I learnt Perl and I'm glad I did. Perl is a good language to start on but the transition from C to perl is alot easier than from Perl to C. Perl is a lot more lenient than C and you will become frusterated because you will be struggling to do things in C that you could to in one line of perl. This may make you give up and just stick to Perl because it seems easier and you can see results faster. If you don't plan ever using C or Java than Perl is a good language to start in but if you have to learn C later on it may be harder or make you a sloppy programmer.

    Right now I'm rewriting a Fortran program in Perl and I've never seen Fortran before in my life. If it wasn't for a C background I think understanding fortran would be alot harder.

RE: Disadvantages of Perl?
by Anonymous Monk on Jun 13, 2000 at 20:56 UTC
    I kind of agree with the fact that Perl might be a bad language to start off in.

    The reason for this is that you can't truly appreciate Perl's ease of use until you've encountered other (horrible) languages such as C.

    But on the other hand, it does give you the basic required knowledge: variables, loops, if constructs and so on.

      Good point. I don't think that I would appreciate all the neat things of Perl if I hadn't spent my time with C and C++.
      The very first thing that made me like Perl were the pop and push functions. When I tried them out, i just set there with a silly smile on my face, thinking about the page of stack code in C++.
RE: Disadvantages of Perl?
by ishamael (Beadle) on Jun 14, 2000 at 07:08 UTC
    I learned perl before C, and now find learning C to be incredibly difficult. whereas in perl i can just say "shift" or "chomp" or something, and pass variables around like potatoes, in C, everythign must be accounted for and kept track of. perl is a good language. but, as a first language ive detrmined its a bad idea. it makes you lazy, and unpreparred for more advanced (and useful) langauges.
    charlie schmidt
    ishamael@themes.org
    www.diablonet.net/~ishamael/
      When you learn a new language, the idea is not to try to write the new language like you did the old. The idea is to apply high level concepts about the type of data and control structures. The example you cite has nothing to do with Perl vs 'C'. People who learn C++ have similiar complaints about going to 'C'.

      Instead, think about how you would implement what you *don't* have, or how you would write code without that language feature. Trying to write Perl in 'C' is futile, just like trying to write BASIC in assembly, or Forth in Perl.

      It's your learning technique that needs to be revised, not the order in which you learn the languages.

      --Chris (who hates language and OS bigotry)
      My background is the complete opposite. I've spent years coding 'C' (never was it fun) before learning Perl. There's no comparison. Perl's a breath of fresh air, it fun powerful and very quick. What more could you want?
RE: Disadvantages of Perl?
by BigJoe (Curate) on Jun 14, 2000 at 02:32 UTC
    I believe like with any language PERL has it's ups and it's downs. And what you need to do is get a base of languages and use what is best suited. Something that needs to be quick and small and run on a single style machine (x86, sparc, etc) I would write it in Assembly. If it needed to be small and fast but be multi-platform C would be the answer. If it needs to handle complex data and be very powerful I would go with C++. And Perl would be for pretty much any thing where you either need it done really fast and easy to modify.

    But it is always fun to do the stuff in PERL though. Because of all the cool features and simple data structures.

    --Joe
RE: Disadvantages of Perl?
by Anonymous Monk on Jun 15, 2000 at 00:42 UTC
    Try Python. It's very simple and very very powerful. I think that eventually Python will replace Perl for larger projects.. Perl is just a very practical script language but it's meant for small to medium projects. You can write larger projects but I doubt whether you can maintain them in a long run. Perl is undoubtedly SPECIAL, but the same way as assembler. It's suitable to use it but for SPECIAL purposes. And CGI scripting and text parsing is what's PERL's designed for. If you want larger projects and code clarity Python is the best choise among beginners.