Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Mother of Perl

by Anonymous Monk
on Oct 01, 2003 at 12:28 UTC ( #295589=perlmeditation: print w/replies, xml ) Need Help??

Why are Perl and its cousins (PHP, Python, Ruby) implemented in C rather than C++?

Can this be interpreted as a failure of C++? What do you think?

Replies are listed 'Best First'.
Re: Mother of Perl
by broquaint (Abbot) on Oct 01, 2003 at 12:42 UTC
    I believe reasoning goes something like this:

    • a C implementation would likely be faster
    • C is more portable (see. compilers are available on more platforms)
    • C has more stable standards (or at least, more widely adopted)
    • C compilers are more consistent
    • lastly, Larry, Rasmus, Guido and Matz also chose C for their own reasons

    Of course those points can be quite contentious, but I think they all hold enough truth to be valid reasons for not choosing not to use C++ for implementing the likes of perl, php, python and ruby.

    I don't think it's a failing of C++, but it would seem that it doesn't really fit into the problem space of a language implementation. If you're interested to see what perl would've been like in C++ then Google about for chip's Topaz.

    HTH

    _________
    broquaint

Re: Mother of Perl (history of Perl in a nutshell)
by grinder (Bishop) on Oct 01, 2003 at 15:31 UTC

    If you're asking this question, you're lacking historical perspective. Perl 1 was released in 1987. Perl 4 was release in March 1991. Perl 5 was released in October 1994. It was at this point that Perl became a really serious language (not that it didn't stop people doing some pretty incredible things with Perl 4).

    Parallel to that, C++ first went under that name (rather than the more informal C with Classes moniker that Stroustrup used) in 1983. This predates Perl development. On the other hand ANSI standardisation of the language didn't start until 1990, and wasn't completed until November 1997.

    I remember those years. Zortech C++ and Microsoft C++ on DOS/Windows, cfront on Unix, all wildly different allowed syntaxes. What worked on one compiler would dump core on another. One had to write in a highly restricted subset of C++ if one wanted portability. There were no templates. There were no exceptions. (That previous sentence may be read at two levels :)

    What this all means is that the earliest vaguely possible opportunity to write Perl in C++ would have been from the transition from 4 to 5. At the time, however, C++ compiler technology was still far too immature. It's as simple as that. The Perl 5 Porters would have spent far more time chasing down C++ oddities than making progress on the Perl core. That's why C was chosen. It was already a mature platform and there weren't many portability issues that abusing the macro preprocessor couldn't solve.

    I can't speak for the other languages.

Re: Mother of Perl
by Abigail-II (Bishop) on Oct 01, 2003 at 12:48 UTC
    IIRC, this is actually explained in the Camel. The prime reason Perl is implemented in C (and one of the reasons the Topaz project is discontinued) is that C compilers are available for about any platform you can imagine.

    This is not true for C++. You do have to realize that Perl runs on a wild range of platforms, a range that goes much further than Unix/Windows/Mac.

    Abigail

Re: Mother of Perl
by jeffa (Bishop) on Oct 01, 2003 at 12:45 UTC
    I am no expert, but the first thing that springs to my mind is objects. The only reason Perl and its cousins would benefit from being implemented in C++ is if that implementation needed to be object oriented. Since each language has it's own OO system, C++ would be overkill, hence C. I would not interpret that as a failure of C++ at all, it's just about taking a the other fork in the road. Besides, what about Objective-C? :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      Don't sugar coat things. Rejection by large parts of the Open Source community is an indicator of failure.

      C++ is superior to C in every respect except:

      1. portability
      2. transparency (or predictability)

      The first can be fixed. C had *exactly* the same problem and we've managed to live through it.

      The second is the fatal flaw. C programmers do not accept hidden costs. The fundamental C++ idea of hiding behaviors (constructors, destructors, operator overloading, etc.) in backwards compatible C syntax was a mistake.

      Strangely, C++ does not have garbage collection because this is seen as a hidden cost. Manual storage management makes C++ tremendously unappealing to anyone but a C programmer -- but the other hidden costs makes C++ unappealing to C programmers too!

      If C++ had used non-C syntax for the non-C parts of the language, I think it would have completely replaced C.

Re: Mother of Perl
by DentArthurDent (Monk) on Oct 01, 2003 at 13:51 UTC
    It can be interpreted as a failure of C++ only to not be the panacea that it was hyped up to be. Most everybody is now determining that C++ has it's uses. There are things that it is very good at. However, it is not the best language for all applications. There are things that make C better than it's offspring, and that is what leads people to still use C.

    This is true of all programming languages. They all have their place, and one mark of a great programmer is knowing when to use the one over the other.

    Ben
    ----
    If I melt dry ice can I swim without getting wet?
Re: Mother of Perl
by Anonymous Monk on Oct 01, 2003 at 23:04 UTC

    There are three main reasons:

    1. As noted above, C compilers are (or at least were) found on more platforms.
    2. It's very easy to write bloated C++ code. One has to be very careful to avoid this, and you usually end up with almost pure c anyways.
    3. More people know C well. More developers = more potential contributors, higher quality code, etc

    Oh, and C++ is a bloated, ugly, language ;-)

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://295589]
Approved by broquaint
Front-paged by bart
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-12-01 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (13 votes). Check out past polls.

    Notices?