From: Chad Perrin Date: 2006-07-27T03:18:52+09:00 Subject: Re: For performance, write it in C On Wed, Jul 26, 2006 at 11:29:06PM +0900, Ryan McGovern wrote: > > > I dont doubt for simple applications and algorithms java is nearly as > fast as C if not equivalent. Though for larger java projects such as > Eclipse, i've had a horrible time of it being slow and cumbersome on the > system, and Visual Studio will run fine and be far more responsive. > I dont really know why that is it could be as simple as some bad code in > the java gui layer that Eclipse is using. Doubtful. Java does generally produce notably faster applications than Ruby, and there are benchmarks that show that in specific instances it can hustle almost as well as C -- even scalably so. A more comprehensive survey of benchmarks, on the other hand, starts to take its toll on Java's reputation for speed. The first problem is that C isn't object oriented and, while OOP can be great for programmer productivity under many circumstances (particularly involving larger projects), it introduces a bunch of interface activity between parts of the program which begins to slow things down. Furthermore, Java's bytecode-compilation and VM interpretation can increase execution speed at runtime by cutting out part of the process of getting from source to binary, but it still requires interpretation and relies on the performance of the VM itself (which is, sad to say, not as light on its feet as many would like). In fact, there are cases where the Perl runtime compiler's quickness makes Java's VM look dog-slow. If your purpose for using a language other than whatever high-level language you prefer is maximum performance (presumably without giving up readable source code), Java isn't an ideal choice. If your high-level language of choice is Perl, there's actually very little reason for Java at all, and the same is true of some Lisp interpreters/compilers. For those keen on functional programming syntax, Haskell is a better choice than Java for performance: in fact, the only thing keeping Haskell from performing as well as C, from what I understand, is the current state of processor design. Similarly, O'Caml is one of the fastest non-C languages available: it consistently, in a wide range of benchmark tests and real-world anecdotal comparisons, executes "at least half as quickly" as C, which is faster than it sounds. The OP is right, though: if execution speed is your top priority, use C. Java is an also-ran -- what people generally mean when they say that Java is almost as fast as C is that a given application written in both C and Java "also runs in under a second" in Java, or something to that effect. While that may be true, there's a significant difference between 0.023 seconds and 0.8 seconds (for hypothetical example). -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "The ability to quote is a serviceable substitute for wit." - W. Somerset Maugham