Objects vs Values this is closely related to the previous post about mutability ...
bnuuy @bnuuy@mathstodon.xyz
Objects vs Values
this is closely related to the previous post about mutability and aliasing, and while the following definitions are nonstandard, they align with intuition.
value: a value is solely defined by its contents, and lives in some platonic space of ideas. there is no such thing as mutating a value, if you changed the contents, you would simply have a different value: you cannot "modify" the number 2. similarly, you can neither create nor destroy them, the number 2 exists independently of us thinking about it or not. when comparing two values, we do so by comparing their contents. whenever we want a second one of a value, we simply make a (recursive, deep) copy of the contents.
object: objects are precisely not defined by their contents. you can mutate them exactly because changing their contents does not alter their identity. but much as mutation didn't even make sense for values, there is also no such thing as "copying" an object; you can create a second object with identical contents, yet not the same ephemeral identity (mutating one does not mutate the other). the closest you can do is copy a special value, the reference to the object, to create an alias.
objects and values form an interesting duality: objects are a sort of container for values; you can't modify the number 2, but you can modify a variable (an object) storing the number 2. in turn, taking the reference of an object gives us a value that behaves as such, that uniquely references that object.
no datatype is inherently one or the other, even if most languages choose for you that small fixed-size things (and sometimes strings) are values ("passed by value"), and everything else objects ("passed by reference").