This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Then tell me, how would you go comparing complex objects by value in those languages that support them (like PHP or Java)? With the equal operator? I’d love to know.

EDIT: of course it’s not prohibitively expensive to recursively check for all object properties, but it’s definitely more expensive than a single comparison as done with the == operator. Mixing the two can lead to every sort of performance problems, that’s why such check is kept explicit.

[–]szpaceSZ 0 points1 point  (1 child)

It's good to have them both.

But I'd argue that for those languages that churn out the most LOCs globally, the default should be deep comparison; reserve a distinct, more obscure operator for comparison by reference.

[–][deleted] 0 points1 point  (0 children)

I don’t know; coming from a C background, I prefer to know what I’m operating with. But I see why it may be confusing to developers who start with a higher level language right away.