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?
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.
| [reply] |
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.
| [reply] |
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 | [reply] |
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? :)
| [reply] |
|
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:
- portability
- 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.
| [reply] |
Re: Mother of Perl
by DentArthurDent (Monk) on Oct 01, 2003 at 13:51 UTC
|
| [reply] |
Re: Mother of Perl
by Anonymous Monk on Oct 01, 2003 at 23:04 UTC
|
There are three main reasons:
- As noted above, C compilers are (or at least were) found on more platforms.
- 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.
- More people know C well. More developers = more potential contributors, higher quality code, etc
Oh, and C++ is a bloated, ugly, language ;-)
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in. |
|
|