Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Perl as a first language

by Anonymous Monk
on Aug 21, 2000 at 17:26 UTC ( [id://28799]=perlmeditation: print w/replies, xml ) Need Help??

Fellow Monks,

We all love Perl for what it can do. However, what it "can do" may be fuzzy. I'm not talking about is it right for a particular job, what's actually running through my head is Perl as a first language for someone just learning to code.

I currently don't have any kids old enough to start learning to program, so it's still academic for me. Is the fact that there is more then one way to do anything good or bad for someone who is just learning to code?

A lesson I learned a long time ago in a different light was "You have to know the rules before you can break them". One of the reasons I like Perl is because it is always trying to do The Right Thing, but could this actually hurt a new coder as they try and learn? Could what they need really be the heavy structure of a different language, so that they "know the rules" before they use Perl?

On the other hand, Perl is very easy to pick up, which leads to some instant gratification. That in turn may keep young minds interested since they can actually see results. Which leads them to using it more in a wonderful self-fulfilling prophecy of being better coders.

So, besides whispering regexs over their cribs, how good of a job do you think Perl would do as a first language for children to learn?

--Jim "Blue" Carstensen

Replies are listed 'Best First'.
RE: Perl as a first language
by merlyn (Sage) on Aug 21, 2000 at 17:30 UTC
    The problem with teaching Perl as a first language is that you never know how much easier it is in Perl than in most other languages. Make them pay their dues first: teach them C++. {grin}

    In all seriousness, I'd still recommend Smalltalk as a first language, if you can find a good set of tutorials that match the implementation you've downloaded (or bought). Smalltalk's advantage is that the syntax fits on the back of a business card (literally!), permits object-oriented programming for everything (in fact, forces it!), provides incredible introspection, and gives very easy access to graphical widgets in the first few hours.

    For implementations, I'd start with Squeak, which has the advantage of being open source and being maintained by the people that originally came up with Smalltalk some 30 years ago. VisualWorks also has a non-commercial personal-use version that seems decent and cross-platform.

    -- Randal L. Schwartz, Perl hacker

      Make them pay their dues first: teach them C++.

      That's child abuse.


RE: Perl as a first language
by chromatic (Archbishop) on Aug 21, 2000 at 21:50 UTC
    Perl makes a good first language for several reasons:
    • It grew out of a need to parse text -- it's built closer to the way people speak than the way machines process information.
    • It's forgiving, quick to develop, and the write-compile-debug cycle is short, thanks to the interpreter/compiler.
    • It's expressive and powerful, but useful even with a small subset of commands.
    • It encourages good programming practices -- if you want it to.
    • There's more than one way to do it.
    It can be tricky for a few other reasons:
    • It's tied to Unix by some syntax and other design decisions. That's a plus, in my opinion, but unless you've learned or are learning Unix as well, some of the higher-powered features of Perl will be harder to understand.
    • It's not a purely functional or object oriented language (thank goodness). That kind of flexibility might make it difficult for someone to learn a new language.
    • There are few enforced disciplines. If you start strictly (pun intended), you'll probably do okay, but if you cultivate lazy habits, you'll have to unlearn them later. More bondage-oriented languages (er... the ones with strong typing and forced indentation rules :) have some initial pain in this area, but rapidly bludgeon you into submission.
    Okay, only the first of those possible cons has much merit. I do believe that learning a handful of languages will make you a better programmer afterall -- and at least one of those should be very low level, either C or some form of assembly.
RE: Perl as a first language
by mrmick (Curate) on Aug 21, 2000 at 19:43 UTC
    IMHO, Perl is great as a first language. I have started a few people off in programming by introducing them to Perl. They were all intimidated with the very notion of programming because they thought that there was some arcane / mystical aura around which programmers performed their incantations and magically conjured up even the simplest of tasks.

    Once they actually wrote a cheezy 'Hello world' and started to learn how to 'program', they dove right into it. No matter what language we use, there are still rules. If we don't follow these rules, our programs will not do what we expect them to. This has to be enforced when teaching someone how to program.

    I learned 'C' as my first programming language. Yes, it made me really appreciate Perl for it's ease. One bonus for someone learning Perl first could be that C's syntax is close enough that the learning curve for C later will be pretty well cut off at the knees.

(jeffa) RE: Perl as a first language
by jeffa (Bishop) on Aug 21, 2000 at 19:56 UTC
    Hmmm, Perl as a first language. Well, I think the most important thing is a good teacher. A good teacher can break a complex learning experience into meaningful parts. Take a look at The Little Schemer, not an easy language to learn (well, at least for us simpletons). But the book has a great way to condition the mind, makes recursion seem, well, elementary.

    The language shouldn't matter, it's how you present the problems at hand. Of course, at some point, any serious programmer will have to learn assembly of some flavor. . .


RE: Perl as a first language
by tenatious (Beadle) on Aug 22, 2000 at 06:03 UTC
    The language is not the issue, or it shouldn't be. The thought processes, the discipline, and the math are what really count.

    When I was first learning basic on an apple II (Ctrl-b got you into basic, from assembler or some other equally useless language), I had a math teacher who told me, "Pursue algebra and it will make you a better programmer, pursue programming and it will make you a better mathematician." It's true enough... How many times do you perform a simple assignment or a join/grep/split that you couldn't have done without algebra?

    When you are first starting out, it's critical that you predeclare your variables and comment your work. If you don't, you don't think about what you are doing long enough to remember it. Putting into plain English what you are doing makes it clear to yourself what you have to do with a given sub or function. It's particularly useful when you start to do OO stuff where you've got to be really careful about what each class and object does.

    The other idea is the thought processes. I have noticed that some people just do not understand that a computer only does what you tell it to do. How often have you heard the complaint, "My computer is possessed!" ... (ehem... except when it really was, by BO...) The point is that all the frustration with "teaching" a computer to do what you want it to do, can be avoided if you sit down and think through each step calmly realizing that each statement is telling the machine to do something in a particular way to a particular thing.

    In my opinion, these are all things that can be taught before a child starts to program. If your children are old enough to begin using numbers, spend time with them drawing clock faces with one hand, ask them to count at all times, do their math homework with them, stretch them beyond what their school is willing to teach, play them in games of chess when they get old enough, make an effort to spend time with them doing intellectual work. It is an effort that you will be rewarded from as their concentration grows. First of all, it will teach concentration and attention to detail, second of all, they will remember the time that you spend with them... and it will be a positive reinforcement kind of thing. Mostly, if you show that it matters to you, they will likely make it matter to them.

      "Pursue algebra and it will make you a better programmer, pursue programming and it will make you a better mathematician."

      Such an awesome insight. I remember when I first started programming on a TI-994a back in 1981 . . . I didn't really understand how strongly math tied into programming.

      On the flip side, I remember having a difficult time finding a pratical use for algebra and trig, my teachers just said "Learn it! You'll need it!" but never said WHY.

      All I needed was someone to say - "hey kid, learn this stuff and you can make video games one day!"

      All well's that end well, though, if I was good at math, I probably never would have pursued music . . .


      Well, my first language had been Commodore Basic V3.5, then I even had to downgrade to Basic V2 (CBM 64). I got me a book on assembler, too, but never really learned it. On a PC, I went on with GWBasic. This is all still in my head, and perl offered so many new horizons. A limited language tends to limit your thoughts, at least in my case. My colleage has never done any 'real programming', he is now working with Macromedia's ActionScript and had a glimpse on my perl scripts and he even understood *a little*. I guess, Perl as a first language might be a good idea. Give the people some good examples that are well documented and then let's see ...
RE: Perl as a first language
by MadraghRua (Vicar) on Aug 21, 2000 at 22:42 UTC
    Actually I've come at it as an almost first language (Basic back in 1984 and then a very long pause). I found that having learned Perl first, I could code very quickly but my coding style was somewhat suspect - I knew what it meant but it wasn't so clear to other folks. It improved when I had to learn C and C++ though. As said before in this thread, a good teacher should help with this.

    My main winge with Perl has been the lack of GUI/graphics capability. Yes I know you can use GD and Tk and all that good stuff, it's just a rather steep learning curve for a newbie by him/herself. Tk involved learning yet another language to use it. GD was sparcely docuemnted and took me a while to pick up too. In many ways Java was a cinch for GUI programming. If you have a teacher, this may help.

    So if you're using pretty pictures as a means of teaching programming skills, and kids love pretty pictures, Perl may not be your first language of choice, IMHO.

    yet another biologist hacking perl....

RE: Perl as a first language
by gumpu (Friar) on Aug 21, 2000 at 21:19 UTC

    Though Perl is a wonderful and fun language, the best language to start with is assembler. No language gives you so much insight in the inner workings of a computer. Once you learn assembler the working and especially restrictions, innerworking, and limitations of other higher level languages are much easier to understand (for instance things as passing arguments by register or by stack, stack overflows, size limitions of numbers, hexadecimal number, optimizations etc). Once that is learned Perl makes an excelent 2nd language....

    Have Fun, Frans.


RE: Perl as a first language
by Dogg (Scribe) on Aug 21, 2000 at 21:22 UTC
    I picked up Andrew L. Johnson's Elements of Programming with Perl specifically because it was directed at someone new to programming. Although I was cheating (I've got some limited C++ experience), I thought it did a good job of explaining the basics of programming (theory/style/design) and then later the basics of Perl. If you're thinking of teaching someone programming, this book might be a great place to start.
RE: Perl as a first language
by ferrency (Deacon) on Aug 22, 2000 at 20:35 UTC
    I think that in order to answer "What's a good first programming language" or "Is X a good first programming language," we need to know more about the background and goals of the person who will be learning to program.

    This can be difficult to do when designing an entry-level programming class for a group of students with different backgrounds and goals, but it is not always impossible (for example, an entry level CS class is likely to use a different first programming language than a web development programming class). And, it's very important to take these things into consideration if you're trying to go it alone and teach yourself how to program- one of the most common reasons I see this fail is attrition due to lack of interest.

    Different people come to programming from different backgrounds. Leveraging someone's previous experience can make it easier for them to learn how to program by either building on knowledge they already have, or by improving their attention span by keeping the experience interesting. For some people, working with a graphical system can keep things interesting. For others, working with something that "looks almost just like a unix shell" is better. And those coming from an html web-development environment would be most comfortable working with something that looks "almost just like HTML."

    At the same time, what the person intends to do with their programming skills is also important. If you're teaching future Computer Scientists, it's probably more useful and important to start with formal (but less frequently used in Real Life) languages with stricter syntax, such as Lisp and Pascal. If you're teaching a system administrator how to make their life easier, through automation of common tasks, but they never really intend to move on to large-scale development projects, then you'll never get anything accomplished with LISP (okay, except maybe in Emacs). Likewise, a web developer- if all they really want to do is spice up some otherwise boring web pages, knowing that you always have to predeclare variables and functions in Pascal isn't really going to help much.

    It's probably heresy in CS circles to suggest that It's Okay to leave gaps in peoples' programming knowledge, that It's Okay to cut corners in order to facilitate Getting The Job Done. Teaching a web designer PHP as their first programming language will probably leave many lessons which would later need to be unlearned if the person eventually decided to go into Computer Science. But not everyone wants or needs to be a computer scientist just to write useful programs (or, to write programs Well, within a certain domain).

    With all of that in mind... "Is Perl a good first programming language?" I'd say Yes, sometimes, for some people.

    One poster commented that it's too easy to shoot your foot off in Perl if you're unexperienced. I claim, it's easy to shoot your foot off in Almost All languages. Perl has the benefit that it's less likely to crash your machine and require a hard reboot to recover, when you do shoot your foot off. And because there's no explicit compilation stage, it takes less time to sew your foot back on and try again.


RE: Perl as a first language
by Corion (Patriarch) on Aug 22, 2000 at 00:50 UTC

    Personally, I don't really think that Perl is a great language to teach and learn as the first language. I've been brought up with (Turbo) Pascal, and I think that first learning strict stuff (like, predeclaring your variables, predeclaring functions, strict count of parameters, strict typing) is very important. After you've learned that stuff, you can move over to the greener pastures of dynamic type conversion etc..

    "Over" in the CS departement, they are nowadays teaching (eeeek) Python, and I think that Python is maybe a good start, since it's very strict in its requirements, and available for a lot of platforms. Note that I haven't written a single line of Python yet :)

    There are other "toy" languages designed specific for learning programming, something in the style of Logo, maybe with another metaphor than the turtle :).

RE: Perl as a first language
by Poetic Justice (Monk) on Aug 28, 2000 at 19:24 UTC
    I don't know about your children. (I have 2 ages 12 and 13) My have no interests in programming at this point in their lives, but I had a summer worker in our IS dept. over the past couple of months. He had a lot of PC experience, but no programming experience. I spent a couple of days working with him on Perl. It allowed him the "instant gratification" factor as well as the "fun" factor to become a part of his work life. He picked up a rudimentary skill in about 3 weeks and now that he is back in school, he is honing those skills. Perl allowed me to teach operators, variables, conditionals in a painless fun way using Randal Schwartz's "Learning Perl". Hopefully he will take this, run with it and turn it into a career. He has the passion, now he just needs the love Poetic Justice
RE: Perl as a first language
by KM (Priest) on Aug 21, 2000 at 22:52 UTC
    I do think Perl is a good first language. Easy to follow, free-form, can do a lot while knowing a little, etc... But, I would choose Lisp (Common Lisp) as a first language if not Perl. Why? As ESR said, "LISP is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot."


RE: Perl as a first language
by d-man (Initiate) on Aug 21, 2000 at 23:28 UTC
    Perl is an awesome language. Probably my favorite to work in right now. But I can't help feeling that that's because I "paid my dues" with C and C++. Think of it this way. You're learning to drive a stick. Do you want to start on a Ford Escort (yes, with the asinine "Shift" lights), or on a Ferrari Testarossa? Clearly, the Ferrari is a better tool for getting the job done (going places quickly and in style), but is it worth the risk of destroying the clutch or wrapping yourself around a tree, just to start with the best tool available to an expert? Like anything else, you need to know the fundamentals before you can excel at your craft. That's why there are beginner's tools and expert's tools. Unix: Where /sbin/init is still Job 1.
RE: Perl as a first language
by extremely (Priest) on Aug 23, 2000 at 05:45 UTC

    Perl is as good a place to start as any. If you look around, you will notice that there were two languages that were invented strictly for teaching (BASIC and Pascal) and both have had remarkable runs as real working languages over the years. Even now you see the newest BASIC (VB 6) up against the newest Pascal (Delphi 5).

    The grim fact is that your first language seriously colors your later choices and mental parsing. So much so that many people are still more comfortable in a majorly bastardized version of their first language than one designed to address the needs of the task they are assigned.

    If you know what type of task you will be performing I recommend you pick as a first language the one you will do most of your work in. If it has been years since you programmed, I tell people that Perl is to Basic what Java is to Pascal. Nothing LIKE it yet strangely familiar.

    As to the original post's question, teach them more than one language at once. I recommend a language like Perl or old BASIC with inflected verbs and nouns (&subs vs sub() and $var vs @var vs $var3); a stricter language like Java or Python with a plainer grammar; and a radical grammar language like Scheme or Forth that makes you look at the logic of the program from a whole different angle.

    There are a lot of good languages out there, make sure you give them a taste of more than one and let them find the once that fits them like an old shoe. Personally I wouldn't be half the Perl programmer I am without Lisp, x86 ASM, Forth, Basic, Pascal, C and more all floating around in there. (Lisp really helped with Perl, one week after first playing with hash arrays I yelled out, "Oh! Dot lists!" =)

    $you = new YOU;
    honk() if $you->love(perl)

RE: Perl as a first language
by takshaka (Friar) on Aug 31, 2000 at 08:33 UTC
RE: Perl as a first language
by the_slycer (Chaplain) on Aug 22, 2000 at 05:30 UTC
    As a newbie to Perl and coding, though not at all a child, I can maybe offer some input..

    I have tried C, using the K&R book, and, although I enjoyed it, I was never able to get into it. I think the reason for this is due to the fact that I had a hard time seeing how far I could take it.

    With Perl, I grabbed the "Learning Perl" O'Reilly book, and immediately saw some possible uses for it. I have taken those possible uses and turned them into actual working code (though probably not the best), and have started asking people what they wanted created. I have written a phone number to word generator (and the other way around), as well as a program that monitors your machine for an IP address change, when it changes, it will then update an HTML page with the new IP.

    Neither of these are the cleanest code, and some would shudder to look at it I'm sure, but they work, in a few short months I have learnt a lot more Perl than I ever did C. Immediate gratification is a very good thing for newbies (like myself).

    Now that I have created my first few applications I am trying very hard to advance both my programming knowledge, as well as style - ie use strict, better structure. I have ordered the 6 cd set from O'Reilly, and am looking forward to going through Perl Programming to advance further.

    Rules are important, no doubt, but IMHO, you have to give the carrot stick before applying the whip ;-)

    In a semi-related note, I would like to be able to throw some code up and have someone tell me what I have done wrong, or what could be better and why, I am completely dependant on just working through the books right now, and would like to know where I need improvement (OK, OK, everywhere, but you know what I mean). I'm not sure that Perlmonks is the best place for that though, some thoughts?
RE: Perl as a first language
by ColonelPanic (Friar) on Aug 22, 2000 at 23:42 UTC
    If everyone learned Perl first, how many would even bother to go on to C++?
      It depends entirely what you intend to do with your life. As I've said before, you can't write operating system code in Perl (barring the silly, impractical scenarios that have been previously discussed). If you want to write Windows applications, Perl is not a good language. Not so much as a language in itself, but the lack of easy interface to the underlying windows functions.

      You *could* write a complete windows app using Win32::API, perhaps, but why? In addition, Windows makes use of many callback functions, and I don't know how well these really port to Perl. Implementing an event driven system in Perl would seem to be a lot more difficult, considering the operating system has certain expectations. And last time I checked (and this may have changed), you couldn't call straight back into a Perl subroutine. At least, not without writing some XS code to manage it all. Which starts to get away from the point of writing in Perl.

      Perl also lacks an effective method for distributing and installing Perl as part of an application. If someone has Perl (and assuming you don't have version dependencies), you'd be OK. But since it's not something that's installed as part of the O/S, and the fact that it's nowhere as easy to install as copying a DLL file out, it makes for a painful application installation.

      Also, IMHO, Tk isn't there yet. And for most Windows users, it doesn't look enough like Windows to make them happy. In fact, one of the points of Windows (and MacOS on a MacIntosh) is to give users a common user interface for applications. Now I'll be the first to admit that some people can't begin to grasp this, and certain basic functions like copying a marked text block aren't control-C in applications. But, the window frame work is basically the same, and generally speaking, the underlying user interface is pretty consistent. With Tk apps, I haven't found this to be so.

      Now, if you're going to spend your life not writing OS code for Linux, and not writing Windows apps, then yes, you may never choose to learn C++. Of course, the more languages you learn, the better a programmer you become. C++ teaches methodologies that are supported but not enforced by Perl. Perl has some powerful OO capabilities, but I believe that using C++ gives you better insight into them.

      Perl is an excellent langauge for many tasks. It is not the solution to every problem out there (How many AI modules do you see for Perl? 1: AI::NeuralNet::BackProp). A good programmer recognizes when to use a given language for a given solution. Not beating every problem into submission would a tool that's not appropriate to the task.


      e-mail jcwren
        -It is not the solution to every problem out there (How many AI modules do 
        -you see for Perl? 1: AI::NeuralNet::BackProp). A good 
        -programmer recognizes when to use a given language for 
        -a given solution. Not beating every problem into submission
        -would a tool that's not appropriate to the task. 
        The people that I learn programming stuff from replaced
        LISP and Prolog with Perl.  They find it easier to use
        and just "way bitchin' cool."  Inference engines work
        just fine in Perl.  
RE: Perl as a first language
by Anonymous Monk on Aug 22, 2000 at 08:07 UTC
    I guess to me....the first language is C/C++
    Cause it's the "Universal Language" and is very easy to define and understand.
    Perl can make you express your thoughts in a such way.
    For newbies Perl is not the real language to start on but it's a great challange.
    But if you want the "dumb's bestfriend" language try using COBOL or Basic.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://28799]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-06-21 16:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.