I was reading about prototype-based languages and this doubt comes into my mind:
Is .NET Object Creation ex nihilo (“from nothing”) and so allow new objects to be created from scratch? Or, instead, is .NET object creation based on cloning from an existing object (i.e. Object) as the cloning prototype for new object creations?
The most basic objects in .Net have no user-wise data, only some internal platform’s information about their type and in-memory location of their actual data. From the user’s (developer’s) point of view, they ‘just exist’ and they only differ in their ‘identity’. Their class cannot be extended in any way. I do not see any point in cloning anything.
More complicated objects are derived from something, and ultimately are derived from the base object. There is no copy-construction and no deep-copying semantics in .Net, so at the level of non-basic objects, there still is no point in cloning anything.
At the level of metadata, each object carries information about what class(es) does it belong to. The metainformation is shared, and all objects of the same class just point to the shared metainformation. Still no point in cloning anything.
Thus, I’d be very surprised if the object creation was done in a prototype-cloning fashion. I do not know with absolute certainity, but I bet that it is not. I’m alsmost sure that object creation is just allocation of small memory block and maybe setting a few pointers inside its header.
It certainly is verifiable if someone *ngen*s some code and disassembles it to see how new() operator works 🙂