http://qs321.pair.com?node_id=454260

DaWolf has asked for the wisdom of the Perl Monks concerning the following question:

Greetings.

I've read on O'Reilly's History of Programming Languages that Perl derives from nawk and sh.

I know that this may sound a little too simple, but I'd like to check if this information is accurate, since I'd like to include this in a course material I'm producing.

Thanks in advance,

Replies are listed 'Best First'.
Re: Perl influences?
by merlyn (Sage) on May 05, 2005 at 11:01 UTC
    I believe Perl predates nawk. In fact, I've claimed at least once or twice that I'm glad nawk (and gawk) were not readily available in 1987, or there might have been less pressure on Larry to write Perl in the first place.

    From what I understand (although TimToady will correct me if I mess up here, perhaps), the problem Larry was trying to solve with awk involved stopping processing in one file to temporarily consult a second file (bug reports that refer to other bug reports). And that's what awk doesn't do, although I understand later awk versions handle fine. So, Larry was "forced" to write Perl, and create an entire industry and subculture as a result.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Perl influences?
by blazar (Canon) on May 05, 2005 at 08:59 UTC
    I've read on O'Reilly's History of Programming Languages that Perl derives from nawk and sh.

    I know that this may sound a little too simple, but I'd like to check if this information is accurate, since I'd like to include this in a course material I'm producing.

    Nah, it's not that simple! There are plenty of descriptions of the various languages that influenced the design of Perl in the many books about the latter...

    However one nice thing about Perl is its nice and thorough documentation. And to excerpt from perldoc perl:

    Perl combines (in the author's opinion, anyway) some of the best fea- tures of C, sed, awk, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, Pascal, and even BASIC-PLUS.) Expression
Re: Perl influences?
by eyepopslikeamosquito (Archbishop) on May 05, 2005 at 12:56 UTC

    From history.perl.org here is an excerpt from the Perl 1.000 release notes of '87:

    It combines (in the author's opinion, anyway) some of the best features of C, sed, awk, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, Pascal, and even BASIC|PLUS.) Expression syntax corresponds quite closely to C expression syntax. If you have a problem that would ordinarily use sed or awk or sh, but it exceeds their capabilities or must run a little faster, and you don't want to write the silly thing in C, then perl may be for you. There are also translators to turn your sed and awk scripts into perl scripts. OK, enough hype.

    Another piece of trivia: the initial release was delayed until the awk to perl (a2p) translator was finished because Larry felt Perl would not be well received without this vital piece.

    Of course, since that time, Perl has borrowed heavily from other languages as well. And the tradition continues today in the design of Perl 6 with a fancy name: The Principle of Borrowing. :-)

Re: Perl influences?
by jacques (Priest) on May 05, 2005 at 16:31 UTC
    Here is the true Perl Story.

    Don't believe what you read in books!

Re: Perl influences?
by gam3 (Curate) on May 05, 2005 at 19:23 UTC
    I think that there was some lisp influences as well.

    I don't see much sh influence though.

    Update: I see the influences now.

    -- gam3
    A picture is worth a thousand words, but takes 200K.

      Some of the file-checking operations (-f, -d, etc.) are taken directly from sh.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      The directional operators to open, and the file test operators come from sh. As does file globbing.

      Caution: Contents may have been coded under pressure.

        More stuff derived from sh:

        • # as comment character.
        • Here-docs (perl's being much more powerful).
        • Capturing command stdout with backticks, i.e. `$cmd`.
        • "$var" interpolates $var, while '$var' does not.
        • Built-in vars: $? status of last command; $$ pid; $0 program name.
        • Having separate "string" versus "numeric" operators, albeit with different names; for example, shell uses = for string equality, -eq for numeric, while perl is more logical (string variants alphabetic), == for numeric, eq for string.
        • && and || operators (ok, C has these too).
        • the tr function seems inspired by Unix tr command, with y synonym to appease sed fanatics (modern day golfers being grateful for said sed fanatics early influence:-).
        • Many other perl internal functions seem inspired from sh or Unix commands, for example: shift, chown, chmod, mkdir, eval, exit, kill, sleep, umask.

      A few other sh influences (sorry if this duplicates a few others... I merely skimmed):
      • The fact that it's a "script": there's no "main" function that has to be declared and executed first
      • The type of a variable is implicit in the variable name
      • The quoting style for "this${var}that" (putting curlies around name as a delimiter when adjacent to more word chars"

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Interestingly, we are "unborrowing" that last one in Perl 6, since you can just interpolate a closure instead: "this{$var}that", and curlies were too heavily overloaded in Perl 1..5.

        But as to the original question, these days it might be easier to list the languages that Perl doesn't borrow something from... :-)

      I think that there was some lisp influences as well.
      Notably, "map".

        I was under the impression that eval was one of the most lispish feature of perl.

        "Most self-respecting scripting languages such as BASIC (some versions, anyway), Perl, Tcl, LISP, and Python have a feature that clearly sets them apart from systems programming languages like C: the ability to treat character strings as little programs."

        Advanced perl programming, chapter 5"

      I don't see much sh influence though.
      I can see many, though, and in addition to those pointed out by others it seems to me that sigils, which are by now so charachteristic (also) of Perl, have not been mentioned yet. But maybe they're inherited from something else - I'm not a language historian after all... oh and while we're at it, maybe it's worth reminding that their syntax is somewhat different in sh's, as they (limitedly) declinate there, as they do in tcl (IIRC).
Re: Perl influences?
by Ben Win Lue (Friar) on May 12, 2005 at 08:46 UTC
    I'm quite sure that Perl has lot's of influences. Fortran, LISP and Cobol (urg) have influenced any modern language more or less. Nobody can deny, that even an exotic language as Simula had a strong influence on Perl 5. And I think that neither Merlyn,Larry nor anyone else involved did any coding in Simula.
    Even traces of Algol68 can be found in Perl (well err somewhere ... 8-})