Content deleted Content added
Hervegirod (talk | contribs) |
|||
Line 29:
::"Value types" is a kind of language feature.<br /><br />In Java, they are called primitives.<br />In C++, the difference can be summed as "Do I own the object directly, or through a (smart of not) pointer?". The difference is very important, as in C++, the last thing you want is to allocate everything through a new, if only because of performance reasons. But I should not have to explain you this, as you claim extensive experience in C++.<br /><br />Anyway, this is exactly the reason why in Java primitives are not objects (I was told they tried having all primitives being true objects at first, but turned back because of performance).<br />In C#, they made Value Types derived from Object, but still made them "primitives" as understood by Java.<br /><br />So Value Types are, as primitives, a language feature.<br /><br />Fact is, Value Types as understood by C# are a first-class citizen of C#, when their equivalent (primitives) are not in Java:<br />C# handles boxing/unboxing when needed, and does not impose boxing/unboxing when it is not needed, for example.<br />Java is unable to handle primitives correctly without always boxing them first (for example, in generics).<br /><br />Thus, the difference in handling Value types/primitives by the two languages is very important, and should be explicit in the current article.<br />[[User:Paercebal|Paercebal]] ([[User talk:Paercebal|talk]]) 13:05, 23 April 2011 (UTC)
::: I fail to see what's specific in Value Types, except Microsoft's marketing maybe. In .NET value types are also boxed / unboxed, because .NET really wraps the primitive values in Objects, and this operation cost a lot, like in Java. Also transparent boxing / unboxing of primitives is also managed in Java, for example this is perfectly valid Java code:
<pre>
List<Integer> list = new ArrayList();
list.add(2);
int value = list.get(0);
</pre>
More than that, if you try to code the same examples provided by Microsoft to explain how Value Types are working, these examples also work in Java, with an almost identical syntax.[[User:Hervegirod|Hervegirod]] ([[User talk:Hervegirod|talk]]) 21:41, 24 June 2011 (UTC)
== Is this entire article directly lifted from some page at microsoft.com? ==
|