Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8146

Re: StringBuilder

From Wanja Gayk <brixomatic@yahoo.com>
Newsgroups comp.lang.java.programmer
Subject Re: StringBuilder
Date 2011-09-19 00:59 +0200
Organization Netfront http://www.netfront.net/
Message-ID <MPG.28e09640efac3e899896c2@202.177.16.121> (permalink)
References (2 earlier) <4e655caa$0$308$14726298@news.sunsite.dk> <MPG.28d6e5a3ee3006899896b2@202.177.16.121> <4e6d1eb6$0$306$14726298@news.sunsite.dk> <MPG.28de0e1952218cb9896be@202.177.16.121> <15369681.1051.1316335323980.JavaMail.geo-discussion-forums@prfh23>

Show all headers | View raw


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 ---

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: StringBuilder Wanja Gayk <brixomatic@yahoo.com> - 2011-09-11 16:35 +0200
  Re: StringBuilder Arne Vajhøj <arne@vajhoej.dk> - 2011-09-11 16:48 -0400
    Re: StringBuilder Wanja Gayk <brixomatic@yahoo.com> - 2011-09-17 02:54 +0200
      Re: StringBuilder Roedy Green <see_website@mindprod.com.invalid> - 2011-09-17 00:27 -0700
      Re: StringBuilder Lew <lewbloch@gmail.com> - 2011-09-18 01:42 -0700
        Re: StringBuilder Wanja Gayk <brixomatic@yahoo.com> - 2011-09-19 00:59 +0200
          Re: StringBuilder Roedy Green <see_website@mindprod.com.invalid> - 2011-09-19 05:07 -0700
            Re: StringBuilder Jeff Higgins <jeff@invalid.invalid> - 2011-09-19 11:38 -0400

csiph-web