Re: How fast is Java?



Jean-François Blais 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?
Try gcj-4.1.
I have been playing with gcj-4.1 and have been writing up my discoveries
at the following url:
http://www.storm.ca/~tabun/
Do text search for "gcj" and you will find info to support you in your
adventures with compiling java natively.
You will find tar.gz's for examples that compile tcp/ip, awt, swt,
glade/gtk, aes(that's math and memory work which is what you like),
cortado, and finally a clarification of -cp and -foutput-class-dir=. in
order to compile stuff without getting all sorts of "type not found" errors.

Keep in mind my goal was to isolate everything and keep everything
simple to understand without resorting to an IDE or ant.
Mastery of -cp and -foutput-class-dir=. will permit developers to put
java sources into makefiles with all the rest of the sources if you so
choose.

You can squeeze more performance with extra optimization switches which
you can read up in the gcj/gcc documentation.

I wish you lots of fun in your discoveries.
.