I sort of understand the motivation for a String Builder class, but do all languages have one? Should they? I’m thinking specifically of PHP, Perl, Python, and Ruby. I know C# and Java do. If the others don’t, why not? Do they not suffer from the same implementation problem? Or do they not care?
Share
Not all languages have a String builder.
C, for example, doesn’t even have strings.
In C++, std::strings are mutable — they can be changed, so there is no real need for a separate string builder class.
In C# (and the rest of .NET), string are immutable – they cannot be changed, only replaced This leads to the problem causing the need for StringBuilder.
Technically, .NET strings are reference types pretending to be value types. This was done to make they act more like the native types (int, float, decimal).