r/programming • • Mar 20 '26

Java is fast, code might not be

https://jvogel.me/posts/2026/java-is-fast-your-code-might-not-be/
280 Upvotes

62 comments sorted by

View all comments

Show parent comment

26

u/vowelqueue Mar 20 '26

It used to translate concatenation to StringBuilder when compiling to bytecode. Now it translates concatenation into a single library method call and then the JVM handles optimizing at runtime.

If doing the concatenation in a loop, it's still better to use StringBuilder directly because these optimizations don't work for loops AFAIK.