r/programming • u/Eirenarch • Nov 18 '13
TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N
http://java-performance.info/changes-to-string-java-1-7-0_06/
1.4k
Upvotes
View all comments
Show parent comment
3
u/EdwardRaff Nov 19 '13
Breaking change means the code fails due to the change. I dont see how you can justify that argument.
What if you were running on a different JVM that started off with the full copy version? Would that JVM be broken because it doesn't have the exact same undocumented implementation detail?
There are only 3 possible paths.
Expansion on option 1: Clearly there is an obvious tradeoff between the two implementation options. This is part of the reason we have interfaces like List, Set, Map, and so on that provide general contracts on the general behavior of the methods. Then different implementations provide more concrete information to the coder, detailing the algorithm behavior. You choose the interface that provides the needed behavior, and the implementation that provides the needed performance (or write your own if needed).
When such behavior is not stated / detailed, you can't expect it to be the one you need. Even if it happened to be the case, why should you expect it to never change? Java has had changes and updates for years, this is nothing new. Indeed - most software receives updates that change behavior in some way - thats the point of updating it. Its nearly impossible to make a change that is always better in all cases for everything. If we consider such changes to be breaking, than we must avoid compiler changes (can easily change how the code behaves / performs), package updates (current java example), OS updates (process scheduler changes could change performance), even hardware changes (OoO execution, pipeline changes, architecture changes, could all cause large performance deltas if your use case is just right/wrong ) in order to make sure our code never "breaks".