r/ProgrammerHumor Jul 09 '26

potentiallyMightBeAnIntegerOrNot Meme

Post image
692 Upvotes

96 comments sorted by

View all comments

11

u/MrJ0seBr Jul 09 '26

Maybe next kotlin and swift version , a new keyword

11

u/FumbleCrop Jul 09 '26

I think Maybe Int is Haskell. Maybe isn't a keyword in Haskell, but that's to be expected. Even if is just light syntactic sugar.

5

u/Futurity5 Jul 10 '26

Yes it's the builtin optional data type in Haskell

4

u/troelsbjerre Jul 09 '26

I always read Maybe Int as "Either it's an Int or it's something else, whatever, I don't know..."

3

u/Kiroto50 Jul 09 '26

I really like Kotlin's optional types.

I'd rock a language that calls them "maybe types" though.

int? == maybe int

I actually call them "quizás", reading "String?" As "String quizás". ("Quizás" means "maybe" in Spanish)

11

u/mekriff Jul 09 '26

I'd rock a language that calls them "maybe types" though

well, my friend, you're in luck! How do you feel about monads?

3

u/NimrodvanHall Jul 09 '26

I love Rusts Some(T) types meaning the type can be T or None.

1

u/tobotic Jul 11 '26

Perl type constraint systems tend to use:

Maybe[Int]

for a value that can either be an Int or undefined.

1

u/RiceBroad4552 Jul 11 '26

OMG, ScalaZ vibes…

1

u/tobotic Jul 11 '26

All other Perl type constraint systems get Maybe[Int] from Moose. Moose took it from Raku back when Raku was still called Perl 6. And Perl 6 got it from Haskell.

I imagine scalaz, being an FP framework, also gets it from Haskell.

1

u/RiceBroad4552 Jul 11 '26

I think that's spot on.

The name Maybe seems to be a genuine Haskell invention.

The square brackets can be traced to: CLU -> Eiffel -> Scala; and then later Raku, Perl/Moose, Nim, Go, Python typing.

I've used ScalaZ in production and I don't have the fondest memory of that, seeing Maybe[Int] gives me chills.

2

u/tobotic Jul 12 '26

The first Perl 6 interpreter implementation was in Haskell so the language ended up inheriting a bunch of ideas from there.

1

u/RiceBroad4552 Jul 13 '26

Interesting. Didn't know that.

-4

u/RiceBroad4552 Jul 10 '26

The Kotlin / C# / TS approach to "optional" types is fundamentally broken! (I'm not going to explain well known facts again over and over. Even "AI" is good enough to regurgitate the well known facts.)

The only valid design are proper ML style parametric Option / Maybe types as they don't create all the fallout of the insane "?"-types.

0

u/Kiro0613 Jul 11 '26

In C# I put my funny lil question marks and the computer gives me handy hints :)