It doesn't really matter which version of the Java platform you use, does it? Well I know for sure that thread context switching is expensive. Isn't it? OK, but there's no doubt that 32-bit Java Virtual Machines (JVMs) are faster than 64-bit JVMs. Right? The truth is, most of the things we think we know about Java performance …
Same ol' ...
Here's a performance engineering truth that was known even before Java was a twinkle in Sun's eye: do not assume that you, as a programmer, can predict the performance characteristics of your code. Software has been too complex to do that properly for at least two decades. Avoid ugly precautions against non-existant issues, write code as elegantly as you can, and be very grudging about sacrificing any elegance for performance, doing so only where usage-realistic profiling has proved it to be necessary.
Tony Hoare famously stated, “We should forget about the small efficiencies, say about 97% of the time: Premature optimization is the root of all evil.” (For some reason this maxim is often attributed to the great Donald Knuth, but when Knuth said it he made it quite clear that he was passing on an insight from Hoare.)
The great value of this article is that /we don't always know a premature optimization when we see one/ because it's buried in our assumptions. And as John above implied, trying to outguess the compiler, optimizer, pipeliner, L1 and L2 cache, etc. on a machine that's doing a thousand things you don't even know about is as premature as it gets.
Paris because he said "premature"... hur hur...
I got lost on the way, JVM 1.6 lot faster, context switching good & lock fairly OK ... so why is this piece that slow???
Have they any idea that could be worth reading?
It's a pity.
"Premature optimization is the root of all evil"
Is this an advert for Tapestry, or one of a hundred other frameworks, named because you have to stitch it together yourself, and it's like a medieval war getting it working.
Still at least you can't criticise their naming conventions. You can't say you weren't given clues about what you were getting.
Take Spring, for instance, it's clear they're trying to make money by fooling people into thinking it means "Spring into action" when in fact it's equivalent to Hibernate which is more honest because it's explicit that anything you write in it, won't wake up until after the thaw.
There's no real argument you can place against Java. You point out that one library is crap, and they say, well you should be using any of another dozen different freeware installations, and when something goes wrong, they all start salivating because "It's a great challenge that there's noone to ring, and I'll just ask the brotherhood if any of those has come across this feature."
It's like feminism, or religion. No two people have the same opinion of what it should be, other than whatever you want to do, it will be the opposite. No two people practice the same ideology, and and whatever arguments you propose against any of the flaws, they say, "It's not meant to be like that."
I don't know why Java's even got version numbers, they should just name them after rivers or something. Or better still, how many more machines you're going to have to buy to run the ridiculous middleware frameworks.
Meanwhile the Project Manager's crying in my office.
Minor point about contended synchronization
Concerning performance of contended synchronization:
If you're using Java 5, and you're considering hand-coding a synchronized data structure as opposed to using something directly from the concurrency framework, note that the explicit synchronization provided by the Lock class is implemented differently (native "testandset" and "testandswap" operations) than it's implemented with the implicit "synchronized" keyword, and is even faster. In JDK 1.6, those improvements were put into the implicit synchronized code.
Much of this is described in "Java Concurrency in Practice".
- +Analysis Microsoft: We're making ONE TRUE WINDOWS to rule us all
- Climate: 'An excuse for tax hikes', scientists 'don't know what they're talking about'
- Analysis Nadella: Apps must run on ALL WINDOWS – PCs, slabs and mobes
- Apple: We'll unleash OS X Yosemite beta on the MASSES July 24
- Yorkshire cops fail to grasp principle behind BT Fon Wi-Fi network