tags:

views:

1069

answers:

5

Why is the Objective-C object type called 'id'? As opposed to, say, 'object'?

+1  A: 

Maybe it's the id of the class system (as in Freud's id/ego/superego) - that would make a bit of sense given the id is the basal nature of an organism. Not that I believe any of that Freud rubbish anyway :-).

Or, maybe the developers of Obj-C came from the UNIX school of namers (with "ls" or "cd") rather than the VAX school (with its "show directory" and "set directory").

Or, it could stand for instance data, which is probably more likely.

paxdiablo
+2  A: 

Theory without proof :

How about 'identity' because it is a pointer to any unique object.

Ryan Townshend
A: 

As Ryan notes, it is actually a pointer: IIRC it is NSObject *.

As for the naming - maybe the namer uses a Dvorak key-layout. 'id' is really easy to type in that case (it's like typing 'gh' on Qwerty).

Matthew Schinckel
It is a pointer, but it's a pointer to an object of type struct objc_object, not a pointer to NSObject.
mipadi
Cocoa has other root classes besides NSObject; id could reference NSProxy, for instance.
Marc Charbonneau
+23  A: 

It is called id because that, literally, is all the type represents - an identifier.

Quoting Brad Cox from Object Oriented Programming: an Evolutionary Approach (actually, the first edition, one of the first OO books I bought): An id consumes a fixed amount of space, wide enough to identify as many objects as may exist at any one time. This space is not the same as the space occupied by the private data in the object itself. Object identifiers are fixed-sized numbers,...

Andy Dent
Upvote for referencing the creator!
Ryan Townshend
+3  A: 

I guess the other possibility not mentioned here would be that the Objective-C folks were Latin buffs and based it off the singular nominative/accusative (subject/object) forms of the Latin pronoun id (meaning "it"). It is sort of a generic word directed at a specific object, and id is a pointer to a generic object, so, you never know:).

Lawrence Johnston