Re: Efficiency in Java
"sara" <sarasara82@gmail.com> writes:
I am working on a project and I want it to be as fast and efficient as
possible. Do you know any website or book which talks about hot to make
programs fast by using different data structures?
Optimization might not be /that/ evil as it sometimes is said.
After all, some products have as their main problem that they
are too slow.
Also, some early design decisions might have a critical impact
on the speed, so that even early optimization might not be
that bad.
However, the problem might be the idea to teach or learn
optimization in isolation from other aspects of programming,
Java and computer science.
If someone is well educated in computer science (e.g.,
algorithms and complexity), in Java and the JVM and software
concepts (patterns, paradigms) and tools (like profilers) he
will also have learnt what makes software slow and what makes
it fast. He will not need a separate education on the topic.
However, when someone would try to apply a toolbox of
speedup-tricks in isolation from other aspects of software
quality and trade-offs with them, it might have the opposite
effect or could endager the correctness of the software.
Additional problems are that tricks or strategies that speed
up a Java program might slow it down on a later version of the
JVM or on another JVM than that of Sun Microsystems, Inc.
An important aspect of runtime efficency might be
memory-locality, e.g., execution of code that already is in
the cache of the processor is faster that execution of code
that needs to be read from RAM. Or the success of branch
prediction. But the more abstract and high-level the language
is, the more difficult it might be for the programmer to
foresee this.
This might be somewhat out-of-date:
http://www.cybergrain.com/tech/writing/efficient-java.html
Then there also is
http://java.sun.com/docs/books/effective/
and
http://java.sun.com/docs/hotspot/PerformanceFAQ.html