Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know what language you are using, but what performance gain does using string builders give you?


when concatenating strings, stringbuffer can be orders of magnitude faster. one c# example from google search "stringbuilder vs string benchmark" from codinggame.com measures 2.5 minutes for string += and 99ms for stringbuilder.


Maybe for Python a stringbuilder is faster, but for JavaScript, += is faster.

https://jsperf.com/javascript-concat-vs-join/2

Don't assume a certain way of coding is faster because you read it on the Internet, actually profile your code.


> Maybe for Python a stringbuilder is faster, but for JavaScript, += is faster.

I am amazed and saddened, that in 2020, concatenating strings, regardless of the form or language, is not blazing fast across all environments.


sry i meant stringbuilder, not stringbuffer.


They allow you to change the complexity from O(n^2) to O(n).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: