title: The difference between a destructor and a finalizer?
body: <p><strong>Please Note: This question is about the difference in terminology between the words "destructor" and "finalizer" and their correct usage. I have merely provided examples of their use in C# and C++/CLI to demonstrate why I am asking the question. I am well aware of how it is implemented in both C# and the CLR, but I am asking about the correct use of terminology.</strong></p>
  
  <hr>
  
  <p>In the C# world the terms "destructor" and "finalizer" seem to be used pretty much interchangeably, which I suspect is because the C# specification describes the non-deterministic cleanup functionality using the word "destructor", whereas the CLR documentation always uses the word "finalizer", so within the realms of C# they mean the same thing.</p>
  
  <p>However, in the C++/CLI specification there is a distinction made between the two. It allows both deterministic and non-deterministic cleanup, and uses the term "destructor" for the deterministic functionality and "finalizer" for the non-deterministic functionality:</p>
  
  <blockquote>
    <p>The finalizer provides non-deterministic cleanup. A finalizer is a "last-chance" function that is executed during garbage collection, typically on an object whose destructor was not executed.</p>
  </blockquote>
  
  <p>Additionally the Wikipedia descriptions of <a href="http://en.wikipedia.org/wiki/Destructor_(computer_science)" rel="noreferrer">destructor</a> and <a href="http://en.wikipedia.org/wiki/Finalizer" rel="noreferrer">finalizer</a> indicate that destructors and finalizers are separate concepts, and supports the C++/CLI spec's use of the terms with regard to determinism:</p>
  
  <blockquote>
    <p>Unlike destructors, finalizers are not deterministic. A destructor is run when the program explicitly frees an object. A finalizer, by contrast, is executed when the internal garbage collection system frees the object.</p>
  </blockquote>
  
  <p>The questions:</p>
  
  <ul>
  <li><p>Is there, from a computer science point of view, a clearly defined difference between a "destructor" and a "finalizer", or is the terminology something that can only be defined contextually?</p></li>
  <li><p>If there is a clearly defined difference, then why would the C# spec use the 'wrong' terminology?</p></li>
  </ul>