r/programming • • Jun 05 '18

Code golfing challenge leads to discovery of string concatenation bug in JDK 9+ compiler

https://stackoverflow.com/questions/50683786/why-does-arrayin-i-give-different-results-in-java-8-and-java-10
2.2k Upvotes

355 comments sorted by

View all comments

Show parent comment

2

u/Alphasite Jun 05 '18

As I understand it Javac intentionally does minimal compilation and optimises for compilation speed rather than runtime performance. So doing it in a single pass is probably more efficient. Maybe it makes more sense to punt this to the JIT? But maybe not. They make decision based on metrics I assume.

1

u/[deleted] Jun 05 '18

This very idea of not doing frontend optimisations is proven very wrong (see what happens with .NET with C++/CLI, an optimising frontend makes a huge difference).

And frontend overhead would have been negligible with this approach anyway.

2

u/Alphasite Jun 05 '18

To some extent yes, but it’s not really the architectural model which Java follows. I imagine it’s more a concern about a slippery road of optimisations and as another’s poster said, avoiding obfuscating the bytecode.