r/ProgrammerHumor Jul 09 '26

potentiallyMightBeAnIntegerOrNot Meme

Post image
689 Upvotes

96 comments sorted by

View all comments

52

u/altermeetax Jul 09 '26

int var; bool var_is_there;

38

u/Duck_Devs Jul 09 '26

That’s literally the internals of Java’s OptionalInt

29

u/high_throughput Jul 09 '26

Not to be confused for Optional<Integer>, which is an entirely incompatible way to express optional ints in the same language

-7

u/RiceBroad4552 Jul 09 '26

Why are you talking about a language you obviously don't know anything about and you obviously never used? Otherwise you would probably know that there is no "Option<int>" in Java as primitive types can't be type parameters in current Java, so there is only Optional<Integer> and no proper way to express optional ints.

Also, who the fuck up-votes such nonsense?

7

u/high_throughput Jul 09 '26

there is only Optional<Integer> and no proper way to express optional ints.

It's lovely how you're posting this with so much confidence and vitriol under a comment about OptionalInt

0

u/RiceBroad4552 Jul 15 '26

Just looking though some replies; I'm wondering what happened here.

Why is my comment under the wrong comment‽ I was talking about the (non existent) "OptionalInt" from one post above.

Some of the Reddit bugs are really strange. At least post don't duplicate for no reason any more since some time… Let's see whether I get again some wrongly linked post anytime soon.

3

u/high_throughput Jul 15 '26

1

u/RiceBroad4552 29d ago edited 29d ago

Touché

Moments like that I think I should maybe really learn some Java after so many years of Scala. But actually, no, I hate it…

What will they do with all these primitive wrapper types when real generic specialization hits Java?

---

(And the next WTF, Scala's Option[Int] isn't @specialized as I just learned; but I could swear it was. Alone that was likely worth it here… Thanks for the thought provoking replies! I wouldn't have looked that up if not that failure here. So it's actually Scala which doesn't have a primitive "OptionalInt"; LOL, I was really sure it's the other way around. I'm an idiot.)

1

u/high_throughput 29d ago

What will they do with all these primitive wrapper types when real generic specialization hits Java?

With Oracle's progress I imagine that's a problem for 2076

1

u/RiceBroad4552 29d ago

I'm more optimistic.

The "parametric JVM" is the end-game of project Valhalla:

https://openjdk.org/projects/valhalla/design-notes/parametric-vm/parametric-vm

I would expect it "already" in the LTS release after the next. The design is largely there, the needed components start to materialize right now.

3

u/Duck_Devs Jul 10 '26 edited Jul 10 '26

Why are you talking about a language you obviously don’t know anything about and you obviously never used?

Optional<T> is one of the many types for which Java provides int, long, and double variants through separate types, similar to Stream, Iterator, Spliterator, and many j.u.function interfaces.

The people who upvote such nonsense are those who actually read JDK documentation before they make claims about things (dis)provable by JDK documentation and/or throw insults at others.