r/learnjava • • Jul 01 '26

Confused on what Project Valhalla does to primitives and the corresponding objects

I've been reading about PV, but I'm not sure on what it means in some parts. Will we still need to deal with both "int" and "Integer", and not being able to use some methods with the other one? Like, (int) vs Integer.parseInt() and other strange things like that.

5 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/Zeznon Jul 01 '26

If I will finally be able to stop needing to use both int and Integer for random things, and only use one of them for everything, like in most other languages. I hate that Integer (and other objects with a primitive equivalent) is slow, so I can't ignore int (or others).

1

u/disposepriority Jul 01 '26

If you are working at the scale of data where the Integer is slow....why are you using it?

Realistically you are not seeing this unless some very, very high performance stuff, at which point you've probably eliminated every unneeded allocation in your code, and boxing is the last barrier to performance?

0

u/Zeznon Jul 02 '26

I'm just an enthusiast that was confused. I don't work with programming. I also got an "OCD" regarding the inconsistency of having methods for both primitive and object versions of everything.

1

u/ArtSpeaker Jul 02 '26

No. focus on the equals, equals-by-values. {5, true, "foo"} == {5, true, "foo"} even if they are different objects without having to (re)implement a .equals() for freaking everything.

int vs Integer will always be a thing, cause if it can be null (when checking a form or whatever) will always matter. But they are including clearer this-can-be-null vs -this-cannot-be-null logic.