On 06/10/2012 04:03, Chad J wrote:
Try to do array slicing in Java or C#.  You probably won't be able to do
it.  You'll get string /copies/ and this will incur heap allocations in
the GC heap.  Those languages /need/ good garbage collection to be
performant because they abuse the poor GC heavily.

In fairness to Java, it does share the inner char array between strings when you request a substring. (Inside the String class you'll find a reference to a char array, and 'start' and 'count' ints.) The String object itself though (which is small and wraps the char array reference) is allocated new each time. Java's GC is rather good though, so it totally gets away with it.

Reply via email to