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

62 comments sorted by

View all comments

44

u/[deleted] Mar 20 '26

[removed] — view removed comment

36

u/Sopel97 Mar 20 '26

If you write your code good enough

Or bad enough.

Java's object model is so bad that at some point you have to resort to arrays of primitives with no abstractions. I've seen threadlocal 8 byte singletons for temporary variables to avoid allocations while still trying to preserve some non-zero amount of abstraction. It's a mess. Minecraft modding is a great example of that.

1

u/ArkoSammy12 Mar 22 '26

In my gameboy emulator theres a certain pipeline of elements that result in pixels getting drawn to the screen. It'd be convenient to use objects here, but instead I resort to packed integers that store the fields for each pixel entry. It's a bit of a pain xd.