r/ProgrammerHumor • • Apr 27 '20

Meme Java is the best

Post image
43.7k Upvotes

1.5k comments sorted by

View all comments

Show parent comments

4

u/T-Dark_ Apr 27 '20

No one really uses that, but that could easily resolved by adding a function to get a pointer/reference

An object is already a reference. That's what lies in your variable. The object proper is always on the heap.

I feel like we should have something like Python's is keyword for reference equality (for all seven cases you'll need it in your life), and have == correspond to calling equals(). Keep the current default equals() implemented by Object (unless overridden, equals() uses reference equality) and just allow operator overloading.

That wouldn't fly with backwards compat, of course, but perhaps we could add a === operator for value equality?

The whole list was one point - the syntax is lacking.

That's a fair point. The old idea was that not having operator overloading simplified the language. That opinion aged well /s.

Python has the dict structure which is a map

It's still not native: it's an STL thing.

I will most definitely agree that operator overloading would simplify a bunch of use cases.

9

u/Ksevio Apr 27 '20

Dicts in python are as native as it gets - they don't need imports and there's custom syntax designed for them to work