in reply to Perl vs. Compilable Language

Programmer performance or machine performance?

When it comes to machine performance, comparisons that I've seen suggest that Perl has similar performance to Java. C++ is significantly faster.

Of course when it comes to productivity, Perl is faster than Java is faster than C++.

Optimize for the kind of performance that you need.

Replies are listed 'Best First'.
Re^2: Perl vs. Compilable Language
by Anonymous Monk on May 02, 2005 at 15:54 UTC
    Of course when it comes to productivity, Perl is faster than Java is faster than C++.
    That entirely depends on your programmers. A lot of people absolutely hate to program in Perl. And they'll love Java or C++. They will be a lot more productive in Java or in C++. Lots of others absolutely love Perl, but they just don't get it. Perl gives that too much rope to hang themselves. Sure, they may "finish" a program quicker than their coworker doing it in Java. But their programs take longer to debug, and get send back from qa more often than the Java programs.
      The implicit condition is "among programmers of similar aptitude for the respective languages." Comparing apples to apples.

      It's hardly a revelation that inept programmers in virtually any language will be outperformed by highly skilled programmers in virtually any language.


      Caution: Contents may have been coded under pressure.

      Familiarity does play a role, but Perl has a very low LOC:FP (lines of code per function point) ratio. There's a table here which compares several languages (it's toward the bottom of the page). Function points are a well-defined measure of how much work a program does, so the LOC:FP ratio more or less compares the sizes of programs that do the same thing in different languages.

      In the referenced table, assembly has a LOC:FP ratio of 575. C runs 225. Fortran runs 210. C++ and Java run about 80. Perl weighs in at 50.

      The ratio matters because research has shown that the cost of a single line of code remains more or less constant regardless of what language you use. Languages that do the most with the fewest lines of code tend to be more economical over the long run.

      No matter how familiar someone is with C++, they still have to write a certain amount of memory management code. Java has garbage collection, but you have to write the boilerplate and conversion code associated with its strict type system. Those trim back some of the advantages gained from familiarity.

      The ratio is just an average, though. And for the relatively small difference between Java/C++ and Perl, there are plenty of other factors which can tip the balance either way.

        I don't give LOC:FP much weigth. Sure, it's nice that Perl has a possible low LOC:FP, but take that to the extreme, we'd all be golfing all the time.

        In many cases, given various ways of handling a small task (a "function point" for instance) the clearest solution is often the most wanted. And that can easily take two or three times as many lines as the shortest.

        The ratio matters because research has shown that the cost of a single line of code remains more or less constant regardless of what language you use.
        I'm not so sure about that. I write both Perl and C code for my living, although I write far more Perl than C. I've been programming Perl for over 10 years, and C for over 15. My Perl programs use less lines of code than my C programs, for doing similar tasks. But I tinker with my written Perl much more than with C. With C, there's often one obvious way, a standard idiom, or when it's written, it's not worthwhile to redo it. But with Perl, there's always yet another way. There's always the itch to change a few lines, to make it just a tad bit better.
Re^2: Perl vs. Compilable Language
by Anonymous Monk on May 03, 2005 at 15:21 UTC
    Of course when it comes to productivity, Perl is faster than Java is faster than C++.
    This is true if you are editing code in emacs or vi or the like. But if you have a awesome editor such as Eclipse when you are writing Java, Java becomes much, much easier and faster to code than perl. The editor looks up functions for you (and there documentation), compiles on the fly and tells you where errors are instantly. It saves tons of time.
      But if you have a awesome editor such as Eclipse when you are writing Java, Java becomes much, much easier and faster to code than perl. The editor looks up functions for you (and there documentation), compiles on the fly and tells you where errors are instantly. It saves tons of time.

      And yet I still find myself being more productive with Lisp/Perl/Ruby and similar languages than I am with Java and IDEs like Eclipse or IntelliJ. Frankly the only thing I miss about Eclipse in the Perl world is decent refactoring support - which is a hard problem with Perl I freely admit.