Article View: comp.lang.misc
Article #4300Re: Relative Speed of Perl vs. Tcl vs. C
From: Tim Hollebeek
Date: Sun, 21 Jan 1996 22:14
Date: Sun, 21 Jan 1996 22:14
47 lines
2826 bytes
2826 bytes
Fergus Henderson (fjh@munta.cs.mu.OZ.AU) wrote: : yogi@shellx.best.com (Yogi) writes: : >Can't seem to find any info on statements I have read that seem to conflict: : Have you ever heard the phrase "Lies, damned lies, and benchmarks"? : >Somewhere I have read that Perl coded grep runs as fast or faster than C : >coded grep in Unix. (Larry Wall wrote this, correct me if I'm wrong.) : Sounds quite likely to be true. : For this specific task, Perl could easily be as fast as C. You have to remember that Perl program will be about 3 lines long, and most of the CPU intensive work is regexp matching and file operations. In Perl, both of those are very highly optimized C routines. Therefore, such a 'Perl' program is essentially a C program; you are using it for exactly what Perl was designed to do very well. : >And in a CGI-web book I read that Perl is an interpreted language that runs : >10 times slower than C. : For most programs, that is probably true. BTW, 10 times is about typical for bytecode compilers; 7-15 or so is a reasonable range, except where the time is dominated by 'high level' constructs, where it can be 2-3 or much lower, as noted above. : >So what's the real answer, or are both statements true somehow? I know that : >Perl can run faster or slower depending on how you code it, (C too) and : >so I guess you would have to find the fastest C code for a particular function : >and similar fastest Perl code (or Tcl) and compare THOSE programs to get : >a definative answer. An important point, though, is that all 'reasonably' written C programs will run within a factor of 2 or so of 'about as fast as you can get, while for some problems, Perl won't be able to break through about a factor of 7 or so, even if you are a Perl expert. Languages like Perl tend to be important in context where you are willing to give up the speed advantage for some other features of the language. Let's face it; very few applications need C's speed any more. -- Tim Hollebeek | Everything above is a true statement, for sufficiently PChem Grad Student | false values of true. Princeton Univ. | tim@wfn-shop.princeton.edu -------------------| http://wfn-shop.princeton.edu/~tim
Technical Details
Message-ID:
<4dudsf$187@cnn.Princeton.EDU>Path:
arc1-ca.pugleaf.net!cnn.Princeton.EDU!franck!timReferences:
<4dhuoj$cbe@shellx.best.com> <9602122.8425@mulga.cs.mu.OZ.AU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cnn.Princeton.EDU!franck!tim From: tim@franck (Tim Hollebeek) Newsgroups: comp.lang.misc,comp.lang.perl.misc,comp.lang.tcl,comp.lang.c,comp.lang.java Subject: Re: Relative Speed of Perl vs. Tcl vs. C Followup-To: comp.lang.misc,comp.lang.perl.misc,comp.lang.tcl,comp.lang.c,comp.lang.java Date: 21 Jan 1996 22:14:39 GMT Organization: Princeton University Message-ID: <4dudsf$187@cnn.Princeton.EDU> References: <4dhuoj$cbe@shellx.best.com> <9602122.8425@mulga.cs.mu.OZ.AU> NNTP-Posting-Host: franck.princeton.edu X-Newsreader: TIN [version 1.2 PL2]