in reply to Confirming what we already knew

This doesn't surprise me in the least. Seeing a speedup of a factor of 200 or so isn't unusual when turning an algorithm from perl to C. Like it or not, perl has a fair number of inefficiencies built into it, and some of the things it requires to happen, like operator overloading and proper tie behaviour, have unavoidable overhead.

C's a lot more limited, and as such can make more assumptions at compile time, which can generate better code, and that's just fine. (Plus, of course, there's been far more work on any C compiler's optimizer than on perl's optimizer, which can make a pretty darned big difference)

Really does look like you did the appropriate thing--used perl for a fast knock-together project, and moved to a faster language when it turned out to be necessary. FWIW, I don't think you'd have seen much, if any, speed win from going with Java. The cost of moving to Java from perl would've been about the same as moving to C, and C's definitely much faster than Java...

Replies are listed 'Best First'.
Re: Re: Confirming what we already knew
by AssFace (Pilgrim) on Mar 05, 2003 at 21:55 UTC
    Java has actually made a lot of progress and is pretty impressive considering how easy it is to write.

    I would guess that the stuff I am trying to do would be around 5-10 seconds on my laptop - still slow compared to the C of course.

    Java has actually slowed down in the 1.4.x realm - but if you have the IBM JDK and the 1.3.x version - it can catch you off guard as to how fast it is.

    The main issue I have with it is not the speed nor overhead (none of the things I do take up all that much RAM), but it is that Java currently can't be used in clustering - at least not in the ways that I'm familiar with. There are people working on that right now, so perhaps soon enough that will be an option.

    I personally would chose C over Java in terms of speed, but I would choose Java over C++ - certainly not something I would have imagined myself saying in 1995 - and probably not even 2 years ago. But lately it has gotten pretty fast... (and then slowed down a bit :) - depending on which JDK "brand" and which release)
      While Java doesn't inherently suck too badly, at least no more than most other languages, I stand by my statement--it would've been as much work to move from perl to Java as from perl to C, and his win would've been much less. Dunno about C++, as I find that when I write C++ code, the only difference for me between C and C++ is the comment style, so it's not like I'm taking advantage of the language... :)

      The design of the JVM (not Java the language, mind, butt he JVM itself) puts some inherent limits on what can be done to run fast without extraordinary work, but this isn't really the place for that particular discussion.