Re: Help me!! Why java is so popular
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 7 Feb 2007 17:14:20 -0000
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
.
- Follow-Ups:
- Re: Help me!! Why java is so popular
- From: raddog58c
- Re: Help me!! Why java is so popular
- References:
- Help me!! Why java is so popular
- From: amalikarunanayake
- Re: Help me!! Why java is so popular
- From: Jack Kielsmeier
- Re: Help me!! Why java is so popular
- From: raddog58c
- Re: Help me!! Why java is so popular
- From: Mark Thornton
- Re: Help me!! Why java is so popular
- From: raddog58c
- Help me!! Why java is so popular
- Prev by Date: Re: How to make the each looping concurrent thread to improve WHILE-loop performance?
- Next by Date: Re: File I/O problem
- Previous by thread: Re: Help me!! Why java is so popular
- Next by thread: Re: Help me!! Why java is so popular
- Index(es):
Relevant Pages
|