Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!teleglobe.net!newsgate.cuhk.edu.hk!news.netfront.net!not-for-mail From: Wanja Gayk Newsgroups: comp.lang.java.programmer Subject: Re: StringBuilder Date: Mon, 19 Sep 2011 00:59:59 +0200 Organization: Netfront http://www.netfront.net/ Lines: 77 Message-ID: References: <96f358c8-a024-40db-b60b-300186c2f813@o10g2000vby.googlegroups.com> <4e655caa$0$308$14726298@news.sunsite.dk> <4e6d1eb6$0$306$14726298@news.sunsite.dk> <15369681.1051.1316335323980.JavaMail.geo-discussion-forums@prfh23> NNTP-Posting-Host: 77.8.228.152 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1316386799 12253 77.8.228.152 (18 Sep 2011 22:59:59 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Sun, 18 Sep 2011 22:59:59 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8146 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 ---