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

This change is going to destroy the performance of a lot of apps that have not been modified in years.... There are lots of programs that might substring every word in a large block of text...

Letting a programmer use too much memory and have to learn why, and when to copy is much better than drastically changing the runtime characteristics of many existing programs. Not copying is way more efficient, you just need to be in the know-

There are even solution that can do both like conditional copying or keeping track of the parent and doing a conditional copy if needed at GC time.



I doubt it'll be that bad. This new behavior is how .NET has done it all along, and out of all the mountains of code I've written that loop over the words in a block of text I've found exactly one situation where benchmarks showed it was worth worrying about. Not for lack of looking, either.

I'm inclined to think that Java's old way of doing it is an optimization that largely became obsolete when the HotSpot VM came out over a decade ago. The nature of generational garbage collection means that the way this method ends up using memory in practice is rather different from what one might expect at first glance. Combine that with modern CPU architecture and it might even end up being faster because of better cache-friendliness.


Substringing every word in a block of text is actually the ideal situation for the change here...


I think they're referring to what Java's doing:

>Last month, Java changed how it computes substrings.

... [tl;dr: previously always kept whole string, substring just stored indexes]

Java now uses a different method: always copying the substring.




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

Search: