Re: How fast is Java?



In article <43FFEB23.5A7BAF5@xxxxxxxxxxxx>, =?iso-8859-1?Q?Jean=2DFran=E7ois?= Blais
<jeanfrancois.blais@xxxxxxxxxxxx> wrote:


Many must have asked that question. I intend to write a few programs
which will be CPU intensive. I know a little of Java. Would a language
that yields native code, instead of bytecode perfrom much faster?

I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as
the C program. Unexpected result to me. When is Java slower?

What kind of program will I write? Programs for myself only. Only text,
no graphical user interface; batch processing; virtually no I/O. Mostly
comparing, and adding integers. Random access to memory.

Should I use my already installed Javac, or consider using another
language?

This is a question that's difficult to answer. If you were using a lot of
floating point, I'd say Fortran. But who wants to program in Fortran? Not me.
But if you have a lot of number crunching, it's a good choice.

Since these are personal programs, use the language you know if it's fast
enough. If it's not, then look for another. Well written C programs tend to be
very fast. But string processing in C is a pain. Actually it's a pain in Java
(and I like Java). But if I had to do a lot of text processing, I'd probably
look at Perl. (And I don't like Perl. Nothing wrong with it - it's a personal
preference.)

Early versions of the the JDK were certainly slower than C, and Java got a
reputation for being slow. That is no longer than case. The optimizers are a
lot better. But the results will vary with the cpu you use, the program
version, memory, operations ...

If you decide to go with Java, use at least version 1.4x. We have no idea what
version is installed on your machine. (java -version)

Eric
.



Relevant Pages

  • Re: Python or PHP?
    ... If you want to program in a normal language, ... Not in Python or Perl, ... > I doubt if any Perl programmer in the given context would have any ... Why do you think in Java one can call the gc ...
    (comp.lang.python)
  • Re: Learning perl - for experienced programmers
    ... The books are cheap. ... They're more the "ease your way into programming and perl" type ... examples of hideous and unmaintainable Java code there's plenty I'm ... A language is only as bad as the ...
    (comp.lang.perl.misc)
  • Re: Comparing Lisp conditions to Java Exceptions
    ... All the ISO standards in the world will not make the world ... Nothing keeps you from annotating your program with exceptions based on what ... language should adhere to your theory. ... Curiously, although you don't say it, Java has the opposite problem. ...
    (comp.lang.lisp)
  • Re: ARC or ARCH ?
    ... > were right to try to design a better language than Common Lisp. ... Java did this nearly perfectly. ... And it provided automatic memory management. ... Perl is another good example: ...
    (comp.lang.lisp)
  • Re: application and web app technologies
    ... > I am the database manager for a unit of a major state university. ... The problem with Perl is that it seems dowdy and old ... code can be written in any language, as can easy to read code. ... > we haven't started with it, and have not committed to Java. ...
    (comp.lang.ruby)