In article <43**************@sympatico.ca>, =?iso-8859-1?Q?Jean=2DFran=E7ois?= Blais
<je****************@sympatico.ca> 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