Re: Help me!! Why java is so popular



raddog58c wrote:

Sometimes the penalty can be zero or even negative, particularly for
applications which run long enough to eliminate the startup effects of
JIT compiling.


How can it negative? I'm not saying you're wrong, but how can any
byte-coded language outperform a binary language if they are doing the
same thing? It can't, because you have to convert the byte code to
the native binary stream before you can execute it.

At least in theory, the JVM's JITer has more information available to it than a
compiler producing a statically pre-compiled binary would have. Some
theoretical examples:

Is the machine /actually/ a multiprocessor ? If not then some synchronisation
primitives can be replaced by no-ops.

Is a (virtual) method /actually/ overridden by any class loaded at runtime ?
If not then optimisations like static linking or even inlining become possible.

Does the processor have an extended instruction set ? If so then the JITer can
generate code which uses those instructions. (A statically precompiled binary
could include both sets of code, of course, with dynamic switching between
them, but that is not often deemed worth the extra bother).

As far as I know, all of those possibilities are implemented (if only in
limited ways) in current Sun JVMs.


How does one get Java to run faster than a compiled language?

Simple: compare it with a compiled language with a bad optimiser ;-)

FWIW, I think it is /highly/ application dependent, and there is no simple set
of rules you can follow to make Java run as fast as possible. My impression is
that the optimiser in the server JVM, from 1.5 (and presumably later) generates
code which is comparable with GCC -o3 or MS's C++ compiler with all obvious
optimisations turned on -- however that is a useless observation unless the
code in the two languages is trying to do the same thing (e.g. 2-D arrays have
different layouts in C and Java, or a calculation might create many
intermediate objects in carefully-written Java whereas the "same" code in
well-crafted C++ might not).

-- chris




.



Relevant Pages

  • Re: casts
    ... I don't revere Nash as a computer science genius or whatever. ... compiler in a later edition of Visual Basic, ... and your front end GUI in any language that makes ... I've worked in Java before. ...
    (comp.lang.c)
  • Re: casts
    ... and was asked to teach it to prospective computer science majors at ... compiler in a later edition of Visual Basic, ... and your front end GUI in any language that makes ... I've worked in Java before. ...
    (comp.lang.c)
  • Re: casts
    ... This is why most shit programmers refuse to learn languages including ... C Sharp and Java. ... compiler in a later edition of Visual Basic, ... language for processing data. ...
    (comp.lang.c)
  • Re: Cpp Considered Harmful
    ... >> I will observe that many Java IDEs do this rather successfully. ... > Look, if a tool author is willing to fully parse the underlying language, ... > compiler version. ... mentions a header file is in the C compatability appendix. ...
    (comp.lang.cpp)
  • Re: Why this overloading example works this way?
    ... The rules of the Java programming language state that method overloading ... You seem to want the compiler to engage in some kind of reasoning ...
    (comp.lang.java.programmer)