Content deleted Content added
move 2011 talk |
MalnadachBot (talk | contribs) m Fixed Lint errors. (Task 12) |
||
(One intermediate revision by one other user not shown) | |||
Line 52:
: ok, but Mono does support only up to NET 2.0, that had to be mentioned [[User:Hervegirod|Hervegirod]] ([[User talk:Hervegirod|talk]]) 13:18, 26 June 2010 (UTC)
: I am removing that entire section. The "runtime environments" are merely there for reference. This article is a comparison of ''programming languages'' - not runtime environments nor platforms. Please discuss here if you still believe this section belongs here. [[User:Useerup|Useerup]] ([[User talk:Useerup|talk]]) 18:30, 26 June 2010 (UTC)
::I'd say it would be a relevant area for comparison as C#.net or Mono runs on ex. a Sony Ericsson W800i, something Java do, and oposite, C# Mono runs on iPhone os but not SE W800i. Platforms is definitley a place to compare on(as long as you don't start list all Linux Distros etc.) <
:::Yes, but the programming languages are not the VMs (JVM,CLR or Mono). Platforms on which the VMs will execute is definately interesting, ''but not in an article comparing '''programming languages''' ''. Such comparison belongs in the article comparing JVM with CLR. This article should also leave out the JVM/CLR as much as possible. But consider ''soft references''. This is a Java ''platform'' feature which does not have any special syntax in Java. Nevertheless it *is* a concept intrinsically part of Java which directly affects how you ''program'' (not deploy). But including such features because they have direct influence on how you program with the language is not an argument for including the entire platforms and their targeted architectures in a ''programming language'' article. [[User:Useerup|Useerup]] ([[User talk:Useerup|talk]]) 05:06, 23 July 2010 (UTC)
:::Also your argument that ''C# Mono runs on iPhone os'' illustrate the very problem: No it does not. You can cross-compile C# using MonoTouch to produce native iOS executable capable of executing. In that sense, yes, C# can "run" on iOS. But then you would have to include every cross-compilation ability as well. I am sure that there exists some form cross-compilation for Java to iOS as well, at which point such extension arguments become moot because they become all-inclusive. Please try to keep this article a comparison between programming ''languages'' - not platforms. [[User:Useerup|Useerup]] ([[User talk:Useerup|talk]]) 05:12, 23 July 2010 (UTC)
Line 344:
: There is a big difference between C/C++ structures and value types because structures in C or C++ are passed by reference, and they are passed by value in C#. It's the same in Pascal, where records are passed by reference too. Plus there are two kinds of Value types in C#: structures and enumerations. There are enumerations in Java too. Which means that the Value type line is misleading and incorrect. What would be correct would be to have two lines: structures (C# has, Java has not), and enumerations (the two languages have). There is also a specificity in C# because structures are passed by values (contrary to what is done in other languages which have this concept). I have another problem with the table, and most of the article: with almost NO sources, it is 90% OR, even if I agree that a lot of the text may be right. [[User:Hervegirod|Hervegirod]] ([[User talk:Hervegirod|talk]]) 14:41, 28 November 2010 (UTC)
::I think you may want to read up on C++ and Pascal. If I define a class (or struct) in C++ and declare a local variable of that class, it is *not* a reference; it is an ''automatic'' (look it up) object. It is automatically constructed (using a default constructor) and automatically destroyed. It has copy semantics: If I define another variable of the same type and assigns the forst one to it, C++ will "shallow" copy the members from the 1st object to the 2nd (actually, C++ will just copy the memory representation of the object). Also, C++ passes parameters of such type by value, ''unless'' you explicitly specify a pointer or reference type. Demonstration:
<
class Zem
{
Line 360:
std::cout << zem1.question << " " << zem1.answer << std::endl; // outputs "The life, universe and everything? 42"
std::cout << zem2.question << " " << zem2.answer << std::endl; // outputs "What is six times nine? 42"
</syntaxhighlight>
::As you can see, zem2 is ''copied'' from zem1, but their "questions" clearly refer to different objects. If they had been copied by reference there would be only one question. [[User:Useerup|Useerup]] ([[User talk:Useerup|talk]]) 07:49, 29 November 2010 (UTC)
:: @Hervegirod : "<i>There is a big difference between C/C++ structures and value types because structures in C or C++ are passed by reference</i>" : You're wrong. In C and C++, you can pass a struct by copy:
<
// C++ code
Line 384:
foo(value) ; // value is passed by copy
}
</syntaxhighlight>
::Fact is, in C++, you can pass whatever you want by copy or reference (my personal preferred curiosity being the reference to a pointer) or even const reference. The "Value Type" semantics exists, too, on C++: Anything pointed to could be considered to not be a value type (a pointed type? ... :-) ...), but all this discussion is blurred by the fact you have references or pointers to a value type, even when allocated on the stack:
<
// C++ code
Line 403:
pi += 4 ; // now, pi is invalid [pointer semantics]
}
</syntaxhighlight>
:: In C++, the value type (or concrete type) would be something whose meaningful value you access directly.<br />Whereas the pointer type would be something to be access indirectly, through pointer dereferencing, but if you play directly with the pointer (i.e. its address value), then lose its meaningful value (and in the example above, you have a bug). <b>So there is a notion of value types vs. pointed types in C++ (which mirrors the difference between value types and reference types in Java/C#)</b>.<br /><br />[[User:Paercebal|Paercebal]] ([[User talk:Paercebal|talk]]) 15:12, 23 April 2011 (UTC)
Line 416:
For example, for build-in value/primitive types:
<
// Java code
Line 437:
array.get(0) += 5 ; //WON'T COMPILE !!!
}
</syntaxhighlight>
<
C# code
Line 455:
array[0] += 5 ; // fast: and now, 1st element of array is 47
}
</syntaxhighlight>
The example above shows that C# handle build-in value/primitive types efficiently, and as first class citizens (C# value types have methods, and derive from Object, while Java don't).
Line 461:
So, for those user-defined types supposed to behave like value/primitive types:
<
// Java code
Line 508:
}
}
</syntaxhighlight>
<
C# code
Line 562:
}
}
</syntaxhighlight>
And please note that this difference is not mere plain syntactic sugar: There is a major performance cost involved there (allocating millions of small objects is always a problem, both in speed in low-latency cases, and in memory in large data cases).
|