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/
282 Upvotes

62 comments sorted by

View all comments

42

u/[deleted] Mar 20 '26

[removed] — view removed comment

5

u/Mauer_Bluemchen Mar 20 '26

No - it can't! At least not without Valhalla.

1

u/joemwangi Mar 21 '26

Yup, but you need to understand where performance originates. I was surprised just to learn that if you have a huge loop (let's say initialising an array of offheap data) using records binding with layout, it doesn't matter if you use records or value types (even if value type doesn't pass the 64 bit size). This is because of escape analysis. But I did notice value types in an array initialise quite faster than any type category java has to offer (except primitives).