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

0

u/Uncaffeinated Jun 05 '18

I would, but it's hard to tell what you're even trying to argue. But here's a shot

Go on. Decompile first, then analyse, rewrite, optimise. Then compile back. The language you decompile it to would be exactly the IR missing from javac.

Nobody analyzes source level language directly. That's insane. Bytecode is a better starting point, but whatever you do, you're going to have to make up a custom IR for your tools anyway.

Wrong again. Low level optimisations are better with JVM. Domain-specific ones, such as idiom detection, must be done statically.

Why?

What?!? Optimisations make code more suitable for analysis. Try analysing anything at all before you do, say, a usual SSA transform.

That's a transformation internal to the analysis tool. But analyzing optimized code is nearly always harder because optimization obscures human intent.

3

u/[deleted] Jun 05 '18

Nobody analyzes source level language directly.

My point is that doing certain kinds of syntax sugar expansion on a source level language is also insane. See this thread for rationale.

Why?

Because you're likely to lose the relevant information in runtime already. And they can be too costly for runtime anyway.

But analyzing optimized code is nearly always harder because optimization obscures human intent.

Why would you even care about human intent? How "human intent" would help you to do, say, vectorisation?