News for hackers. Stuff that matters.
Re:Java memes which refuse to die by nl on Monday August 27, 2012 @11:19AM (#4439195)
StringBuilders are verbose, but they do make a measurable difference in your code.

The problem with no using them is that then you need to be sure your code is never called by something else that runs it in a loop.

A fair while ago (JDK 1.5 had just been released, so I was still looking at StringBuffer) I did some analysis on the bytecode generated by concatenation.

There is a pretty significant difference:

http://nicklothian.com/blog/2005/06/09/on-java-string-concat...

Re:Java memes which refuse to die by jonhohle on Wednesday August 29, 2012 @09:52AM (#4448497)
The example in that article is fairly dumb (why would you use concatenation as an input to a StringBuffer). The Java compiler converts concatenation to StringBuilder in Java 1.6. In most cases (eight the exception of loops and federated, organized string creation) the + operator is identical in performance to StringBuilder (because that's what it compiles to).