Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Technically, we have this one too: identity, versus equivalence. Just like in the real world: when one thing can replace another (it has the same members or properties), they are equivalent; when modifying one would modify the other (or, if you like, when two of the same thing occupy the same space, e.g. the house at 123 Fake St. and the house at 123 Fake Street), they are identical. There's no need for the word "pointer" in that explanation, notice :)

"Equal", however, means neither equivalence nor identity; it's generally just a math term, meaning "identical/equivalent in magnitude" (where numbers are the only things for which "equivalence" is "identity.") Phrases like "equal rights" imply that the total value of the rights can be reduced to a number, and compared; to put it another way, that the rights are sortable. "Equal" has no meaning for things which cannot be sorted—there can be "equivalent paintings", or "identical paintings", but never "equal paintings."

"Equal" is basically the worst possible term to have absorbed for talking about the comparison of anything other than numbers. The underlying comparison is always one of either identity, or equivalence, and this should be simply stated outright—it causes no confusion, nor are there any special cases for which "equal" is necessary.



I don't know where you're getting this idea that equality only makes sense on numbers. In set theory for example, {a,b} equals {a} union {b}, we don't say it is "identical to" or "equivalent to", it IS the same thing. But we don't necessarily need to define an ordering on sets; the equality makes sense without the notion of sorting.


Aye, you've caught me. Let me rein myself in, then: equality makes sense for value objects only (as value objects have no sense of separate identity; for value objects A and B to be equivalent means that they're also a singular entity.)

That's still a minority of the objects we deal with in programming, though, and again, there's no reason to say "equals" when you can specify "is equivalent to" or "is identical to" instead; value objects will happily give you your expected answer under either comparison, and it will force you to define the comparison for business/model objects (that is, those with IDs) as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: