Re: StringBuilder
In article <15369681.1051.1316335323980.JavaMail.geo-discussion-
forums@prfh23>, lewbloch@gmail.com says...
It should be in any Java book above beginners level.
Like other ancient performance-practices that have been obsoleted by
today's compilers?
No.
What we are talking about is the "+=" part and that part is
still relevant for todays compilers.
And "still" is the keyword. The question remains: For how long will this
hold true?
You said "today's compilers".
Referring to other, nowadays old performance-practices.
And besides what he mention as reasons there are also
the 100 new strings.
So what's the problem with these? before answering, just have a look at
this:
http://www.ibm.com/developerworks/java/library/j-jtp09275/index.html
That tells part of the story, but extra objects still cause both memory and time overhead. Time comes from GC cycles that kick in because you were profligate.
...[snip] ...
Still, If i had to chose whether to trust Brian Goetz' opinion on this
topic or yours, I'm sorry, I'd chose Brian's. I'd prefer to have these
objects discarded in a minor collection than in a major "stop the
world" collection.
Nope, I'm arguing that:
String x="";
for(String s : strings){
x+=s;
}
or
String x="";
for(String s : strings){
x=x+s;
}
Is simple pattern that could be detected by tomorrows JIT-compilers and
But you changed your argument. You _were_ speaking of "today's compilers". Now suddenly you're speaking of "tomorrows [sic] JIT-compilers".
I wasn't.
What I was saying was that (maybe my english is not good enough our you
deliberately want to misunderstand me, just to "win a discussion") there
have been numerous performance-advices which have been obsoletey by
today's compilers and that I expect this one to be an advice that will
be obsoleted by tomorrow's compilers. I hope I'm being clear now - even
though I think that it was clear enough from the beginning.
Besides shifting your ground, you have weakened your argument. It's one thing to program to allow "tomorrow's compilers" to further optimize your code, it's quite another to program to *require* "tomorrow's compilers" to further optimize your code.
Let me put it this way: I would not advice someone to use any
performance tweak by default, but to use the dumb, readable version
instead and optimize only if it really matters.
Kind regards,
Wanja
--
...Alesi's problem was that the back of the car was jumping up and down
dangerously - and I can assure you from having been teammate to
Jean Alesi and knowing what kind of cars that he can pull up with,
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]
--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---