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.
.



Relevant Pages

  • Re: Original Macbook OS died. now no space on HD but also no way to rebuild?
    ... It is very easy to learn to write a program using .net or java. ... learning any language takes longer than a paragraph. ... programming environment is much easier to learn compared to modern ... could compile Java at all. ...
    (uk.comp.sys.mac)
  • Re: Help me!! Why java is so popular
    ... byte-coded language outperform a binary language if they are doing the ... Garbage collection can have an advantage in multi threaded applications, and in Java we can have exact c. ... In a compiled language you can't optimise across the interface call whereas with Java you can. ... Even better you can generate byte code at run time (e.g. compile an expression typed by the user) and then the JIT can compile that to machine code and if it is simple enough inline it. ...
    (comp.lang.java.programmer)
  • 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: Cpp Considered Harmful
    ... >> means of doing some of the things the CPP is currently used for. ... > syntax of #include for the language specified libraries. ... believe it would be trickier in C++ than in Java to accomplish what I'm ... there is often a need to compile a class before it can be ...
    (comp.lang.cpp)
  • Re: The curse of constant fields
    ... feature in the Java language, and decided to write up about it. ... Compile A.java if A.class is either absent or older than A.java. ... I meant that ant make rebuilding everything easy. ...
    (comp.lang.java.programmer)