Talk:Comparison of C Sharp and Java/Archive 3

Latest comment: 7 years ago by 71.66.101.171 in topic Boxing/Unboxing
Archive 1 Archive 2 Archive 3

Value types

C# value types are not syntactic sugar. To meet that definition you would have to demonstrate what kind of code is really generated which you could have written yourself. You cannot do that with value types as they exhibit copy semantics - i.e. they are stack allocated and new copies are created when assigned or passed as parameters. Apart from that, being "syntactic sugar" is not an impeachment. Every single programming language is rife with "syntactic sugar". For loops are syntactic sugar: You can demonstrate how the resulting code can be generated as a result of statements and a while loop (or vice versa). Syntax matters. Useerup (talk) 22:26, 25 October 2010 (UTC)

Response: Value types are not a language feature,end of story, your wrong , give it up. Nobody outside Redmond and MS Fanboys cares about value types. They are not defined in any computer science literature, they are an invented type by MS. Not once in programming in C/C++/python/ruby/java/ADA/perl have I ever heard someone say 'geez wiz I wish I had value types'. You really need to stop arguing with everyone on this page. You keep reverting peoples changes, pretty much disagreeing with everyone where they are saying there is bias. How are we suppose to get rid of bias if you are allowing any real changes? —Preceding unsigned comment added by Bongey (talkcontribs) 14:46, 26 October 2010 (UTC)
C#/MS aren't the first once that use the naming 'value' and 'reference' types for their objects, let me just name ECMAScript (or more commonly known as javascript), which was there long before, and used that including the name. Before you make assumptions, here's a technical (though easy to understand) explanation of what a value type actually is: http://stackoverflow.com/questions/1113819/c-arrays-heap-and-stack-and-value-types/1114152#1114152. Try to link that to C++ and you'll see that a reference type is actually nothing but a pointer to an object (which is stored on the heap) that is stored on the stack, and with value types, the actual object is stored on the stack. So under different names, this feature is present in a lot of programming languages. Aidiakapi (talk) 10:02, 15 September 2011 (UTC)
"Value types" is a kind of language feature.

In Java, they are called primitives.
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++.

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).
In C#, they made Value Types derived from Object, but still made them "primitives" as understood by Java.

So Value Types are, as primitives, a language feature.

Fact is, Value Types as understood by C# are a first-class citizen of C#, when their equivalent (primitives) are not in Java:
C# handles boxing/unboxing when needed, and does not impose boxing/unboxing when it is not needed, for example.
Java is unable to handle primitives correctly without always boxing them first (for example, in generics).

Thus, the difference in handling Value types/primitives by the two languages is very important, and should be explicit in the current article.
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:
List<Integer> list = new ArrayList();
list.add(2);
int value = list.get(0);

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.Hervegirod (talk) 21:41, 24 June 2011 (UTC)

You are mistaken, value types are not boxed/unboxed in .NET like they are in Java. This would be the code in C#:

var list = new List<int>();
list.Add(2);
int value = list[0];

And it would not involve the relatively expensive boxing and unboxing conversions. This goes for any primitive and value type (primitive types are just a subset of value types). int is a value type, and in C# you can define new value types. Only when value types are treated like objects (reference types) are they boxed. You may declare arrays of custom value types and the array will contain the actual values not a boxed references to values. Useerup (talk) 23:23, 26 June 2011 (UTC)

Microsoft documentation says: "Boxing operations occur when you pass a value type to a method that takes a System.Object as an input parameter."[1]. Which is the case for List.[2]. There is a lot of syntactic sugar in C#. Hervegirod (talk) 12:39, 15 January 2012 (UTC)
This thread is more than six months old, so I wouldn't expect much response. However, the documentation you linked says "..takes a System.Object as..". Generic list does not take System.Object as input parameter, indeed, the lack of boxing is one the main reasons for generics to exist and why generic collections are faster than their nongeneric counterparts. List<T> differs from ArrayList (which inherits from IList interface) by strong typing of the collection objects. --Sander Säde 12:59, 15 January 2012 (UTC)
As Sander Säde says, you are linking to the non-generic version (comparable to a "raw" type in java). C# has generic versions of collections and in there you will find a List<T> as was demonstrated to you in the example above. Repeat: Value types are first-class citizens and unlike in Java no boxing is performed when stored in a generic collection of the same type. It has to do with the fact that C# has reified generics and does not erase the type of generics parameters.--Useerup (talk) 16:52, 16 January 2012 (UTC)
Trying to implement a Complex type in C# is a good exemple of what C# can do with value types and operator overloading (kind of new primitive types). It is impossible in Java. — Preceding unsigned comment added by 193.8.222.12 (talk) 10:53, 17 January 2012 (UTC)

Incorrect/Outdate Comparison Chart

It seems that the comparison chart has some mistakes or it's outdated, it needs a java expert to revise it. I think java has some features but in the article it's said it doesn't such as : Implicit conversions,Explicit conversions, Events, Rectangular (multidimensional) arrays, Unified arrays and collections, ...

Also it seems that features of C# is listed, then it compared to java, which is a completely wrong approach since in many cases java has a better and more smart workaround for a problem without needing to have a feature for it. For example java never needs Explicit interface implementation, since it has co-variant return types. — Preceding unsigned comment added by 83.166.30.230 (talk) 17:19, 14 December 2011 (UTC)

The purpose of explicit interface implementation in C# is to hide functionality unless an instance is explicitly casted to the interface type, or to stack method or operator implementation that would otherwise clash (such as IList vs. IList<T> member implementation). So co-variant return types in Java is not equivalent. Dahvyd (talk) 06:28, 15 January 2012 (UTC)
The table is correct:
  • Implicit/explicit conversions: Perhaps they should be termed custom implicit and explicit conversions. Java does not allow you to create a new type (class) and define conversions to be used automatically when resolving parameter types (implicit conversions) or custom "casting" logic (explicit conversions). In C# implicit conversions have been used to allow automatic "promotion" from e.g. int to the decimal.
  • Events in Java exist in the BCL, but it is not a language feature as it is in C# (this WP article is about the programming languages). C# events generate "adders" and "removers" automatically much like automatic properties.
  • Rectangular arrays: No, Java does definitively not have those. Both Java and C# have "arrays of arrays" (also called "jagged" arrays), but only C# has rectangular arrays. Their usefulness can be discussed; they have certain advantages (sometimes better performances under random access) and drawbacks (overhead under sequential access) compared to arrays of arrays.
  • Unified arrays/collections: C# allows a "list" view on arrays and the "foreach" loop uses the unified IEnumerable interface which both arrays and collections implement. In Java, arrays and collections have not been unified; rather the "for" loop has been extended to accept both collections and arrays with the "for each" syntax. But they are actually different statements and you cannot pass an array where a list is expected. You can in C#
Maybe the table needs to be supported by more examples? --Useerup (talk) 16:46, 16 January 2012 (UTC)

Tooo looong... to navigate... comfortably...

Hi all,

When I read this article, I found that I had to skip several sections in order to reach the stuff I was looking for. I got suspicious and downloaded the source code—a whopping 103 KB of plain text! What's worse, it's got several problems like neutrality, original research... and the first section is huge!

Does anyone have any ideas as to how to improve this article? I already added the {{Multiple issues}} template to replace the others. But tinkering with templates does not improve an article.

Thanks,

The Doctahedron, 02:33, 24 January 2012 (UTC)

Split the "feature" table into multiple tables and move them to sections with the text/samples. This will allow them to appear more as section summaries than a single monolith? Cropping some details? --Useerup (talk) 21:11, 25 January 2012 (UTC)
Personally, I'd make the tables sortable and collapsible. I'd also put some tables into subpages. Any suggestions on how to do that? 68.173.113.106 (talk) 19:18, 23 February 2012 (UTC)

String interning

Hello all - I think this article would benefit from a discussion on string interning and how the respective platforms deal with that. Any thoughts? — Preceding unsigned comment added by 57.66.102.70 (talk) 15:08, 17 February 2012 (UTC)

What's that? 68.173.113.106 (talk) 19:15, 23 February 2012 (UTC)

Unified type system

C# (and .NET Framework) has no unified type system. I.e. pointers and interfaces does not derive from the System.Object. Moreover, C# does not allow pointers to be encapsulated as objects. [1]

  1. ^ Not everything derives from object, MSDN Blogs > Fabulous Adventures In Coding

194.54.20.58 (talk) 12:12, 1 March 2012 (UTC)

See http://msdn.microsoft.com/en-us/library/aa664638(v=VS.71).aspx Useerup (talk) 17:28, 1 March 2012 (UTC)

Did you bother to try run that code using pointers? Try to compile this:

class Test
{
  unsafe static void Main()
  {
    int i = 42;
    int* p = &i;
    Console.WriteLine(p.ToString()); // Operator '.' cannot be applied to operand of type 'int*'
    new Stack<int*>().Push(p); //The type 'int*' may not be used as a type argument
    new Stack().Push(p); //Argument 1: cannot convert from 'int*' to 'object'
  }
}

See http://msdn.microsoft.com/en-us/library/y31yhkeb(VS.90).aspx “Pointer types do not inherit from object and no conversions exist between pointer types and object. Also, boxing and unboxing do not support pointers.” 194.54.20.58 (talk) 06:18, 2 March 2012 (UTC)

Find a reliable source which says "no, C# does not have a unified type system". So far there are only sources supporting that C# has a unified type system. You are correct that the native-oriented type "pointer" does not derive from object. But the pointer type is not part of the common type system of C#. It is a type to which you only gain access when you run the extended version of the language which you get access to by compiling with the unsafe option. But it is really down to reliable sources. Remember, Wikipedia is about verifiability. --Useerup (talk) 07:07, 2 March 2012 (UTC)
I found http://msdn.microsoft.com/en-us/library/2hf02550(VS.71).aspx which says that the common type system supports value types and reference types. Reference types can be self-describing types, pointer types, or interface types. So pointers ARE a part of CTS. And pointers are just pointing to an object, they are not objects itself, they are simply an address of an object.
Anyway, if you are concerned using unsafe context, try to compile this: Console.WriteLine((object)default(TypedReference));
.NET Framework has exceptions from its rules, and these exceptions makes statement “Every type is deriving from/can be converted to object.” false. If Microsoft wrote “All types derive from the System.Object base type.” it should also write ”except pointers.” but it didn’t on that page (it did on other, the link is in my previous post). 194.54.20.58 (talk) 07:47, 2 March 2012 (UTC)

Unsigned integer types

I changed the entry for unsigned integer types. Java's char type is an unsigned 16 bit integer. I'm tired of reading that Java doesn't have any unsigned integers at all. It's clearly not true, although the number of unsigned integer types is very limited. The "simple/primitive types" section should probably also be changed. — Preceding unsigned comment added by 86.52.7.203 (talk) 12:02, 2 May 2012 (UTC)

Simplicity vs. feature richness

Wikipedia is great for beeing _SIMPLE_ not for beeing "feature rich". This article evaluates C# as better, because it has more features, than Java. The "missing" features of Java are marked red. Diplomatically speaking, this approach is not very clever. 193.165.212.242 (talk) 11:54, 14 November 2011 (UTC) (cs:User:Pteryx)

The tone of the article makes it seem heavily biased towards C# because it has features that Java doesn't - ignoring whether Java would actually benefit from these features or not, and the fact that the vast majority of them were deliberately left out because of design principles of the language. Then lo and behold when a feature comes along that's in Java and NOT in C# (checked exceptions for instance) the article launches straight into talking about all the disadvantages of checked exceptions! And when the opposite happens, such as with LINQ, the article discusses all the positives about it.

This article has the potential to be good, however at the moment it's nothing more than a load of biased waffle. I use both C# and Java extensively and have no bias towards one or the other, but this page definitely does. 86.26.141.146 (talk) 17:31, 1 January 2012 (UTC)

Once again (see below): this article compares two languages by listing their features and mentioning alternatives on the other side. Because C# has more features than Java, C# comes out as ... well, having more features. There is no bias in that whatsoever. Commenters like you keep coming here on how the article is 'biased towards' C#. I don't see any such bias. Please point it out. There definitely needs to be an opinion piece to explain to people using software that more features doesn't always equate better, but this article is not the place for that, I think. Rp (talk) 18:05, 3 January 2012 (UTC)
Article.isBiased() == false; C# is simply a newer language than Java and thus has more features, because the C# programmers thought of stuff that the Java guys didn't. But that doesn't make it better. How it's used is important as well. Cheers, The Doctahedron, 00:42, 24 January 2012 (UTC)
I use both Java and C#. I prefer C# solely for its support of events. Now I've seen events in old Pascal code, so they aren't exactly a new concept - I know that this is just one example of a feature that Java is missing, but is it really that biased to point it out? After all, C# support on mobile phones is inexistent in most cases, and poor on Android - is there any free C# compiler for Android? This "missing feature" for C# is also pointed out in the article, along with arbitrary-length floats. Yes, Java has a lot of red boxes in that list, but that doesn't mean that the list is biased - just that Java has less features than C#. We could compare C# and Java to x86 assembly, and assembly would be almost a solid pane of red boxes - but this doesn't mean that it is worse or inferior, just that it is intended for a different purpose. 90.194.203.69 (talk) 12:39, 16 February 2012 (UTC)
My understanding was that this is supposed to be a discussion about the semantics of the language, and that the underlying platforms were compared elsewhere. C# has language-level support for a lot of things Java doesn't, so a feature-comparison (an objective way to compare the two) will intrinsically favor C#. — Preceding unsigned comment added by 152.23.122.74 (talk) 20:59, 2 May 2012 (UTC)
I used both C# and Java after a long time with C++. I think the debiasing of the article should be done by explaining the differences of the two languages, not only enlisting them, which has been done at some places where it is written that delegates, for instance, have been deliberately left out. Like in this example, if Java is "missing" some features because it is older, this should be clearified and referenced. If a feature has been deliberately left, again, a referenced information is needed. And I propose to use a four-colour scheme so that deliberately left out features are marked with a colour different than green, yellow, or red.
I think this discussion here shows that the article seems to be biased, but actually lacks referenced clarifications. As I used Java around two years and C# less than a year in projects, I think others with more experience would be more appropriate for the job of adding the missing information. To the experts: Please, please do not forget that you are writing for an encyclopedia. I plead to the prophets of both languages to add facts, if they are interested to add anything, and not a list of dogmas. Sae1962 (talk) 10:25, 3 September 2012 (UTC)

I think that the article is no more biased. I plead to remove the marking that it is biased. Sae1962 (talk) 15:06, 12 September 2012 (UTC)

Be bold, go ahead and remove it. I do think the article still has other issues, though. Mostly structural, but there is also the pesky problem of agreeing on where the language stops and the framework begins. Useerup (talk) 19:19, 12 September 2012 (UTC)

Please PR this page

Please Peer Review this page. Thanks! 68.173.113.106 (talk) 01:13, 10 March 2012 (UTC)

Contradiction

In section 1.1 Features, it says that Java has a Decimal128 data type:

Data types Java C#
IEEE 754 binary32 floating point number Yes Yes
IEEE 754 binary64 floating point number Yes Yes
High precision floating point number 128-bit (28 digits) Decimal type 128-bit (28 digits) Decimal type

The simple answer, as stated in section 1.3.2 Primitive types is NO. Don't worry, I already fixed it. 68.173.113.106 (talk) 03:29, 2 March 2012 (UTC)

I'm adding a "yes (BigDecimal class)". It's a class rather than a primitive, but it's part of standard Java. The distinction is arguably ignorable; e.g. you wouldn't say "scala has no number types at all" because they're all classes. — Preceding unsigned comment added by 94.174.207.151 (talk) 06:09, 6 September 2012 (UTC)
BigDecimal was already represented in the table. Java does not have a simple/primitive type with high precision. It has a arbitrarily high precision type in the class library (which C# does not). All of this is represented in the table. Useerup (talk) 08:22, 13 September 2012 (UTC)

Dubious claim about both languages not supporting arithmetic on all types

This claim is wrong. The issue illustrated by the examples is that the languages do not support byte literals - i.e. a sequence of digits form an integer literal - which cannot be cast to byte without loss. Consequently, invoking an arithmetic operator on a byte (variable) and an integer (literal) promotes the byte to integer (in *both* languages) and performs an integer operation. The result is an integer which - naturally - is not compatible with a byte.

The corresponding problem exists with the claim about the float type. Here the float gets promoted to a double - which is not assignment compatible with float/single.

I suggest removing this section as it is incorrect and misleading. Useerup (talk) 08:20, 13 September 2012 (UTC)


On second thought I moved the section here so that we can correct it before deciding where (and if) it belongs in the article:

--- begin section ---

Both languages do not directly allow arithmetical operations on all primitive types, as they arbitrarily default to int or double:

Java C#
    byte value = 2;
    float price = 5;

    price++;
    value++;
    // Type mismatch: cannot convert from int to byte
    value = value + 4; // <<<
    value += 5;
    // Type mismatch: cannot convert from double to float
    price = 5.7; // <<<
    byte value = 2;
    float price = 5;

    price++;
    value++;
    // Error: conversion from int to byte
    value = value + 4; // <<<
    value += 5;
    // Error: conversion from double to float
    price = 5.7; // <<<

--- end section ---

Platform Support

The table regarding platform support states "Yes" in the C# column for Linux, Mac OS X, and Android. We all know that Microsoft who created and continue to create the C# language have not officially made the .NET runtime work on any of those, but rather it is an open source project named "Mono". At present there is merely a reference to the Mono project page, but I propose actually specifying that it is a third-party implementation, thus not one offered by Microsoft. Hence, I propose that for those platforms it should state: "Yes, but third-party". I already made this change already, but it was reverted because it supposedly doesn't make sense since Java support is third-party. This is absurd. The Java referred to in the article and in Wikipedia in general is that distributed by Oracle, and for C# it is that which is distributed by Microsoft.

Can you please leave your favouritism towards C# alone and please just provide useful information for readers. I am sure it is in the interests of the readers to know that C# does not run on those operating systems without additional third-pary software. Kupraios (talk) 04:09, 26 November 2012 (UTC)

Is Java on Android supplied/supported by Oracle? No! Oracle actually sued over that. I am sure it is in the interests of the readers to know that Java does not run on that operating system without additional (and controversial) third-party (Google Dalvik) software. See how that argument can be used against Java as well?. I ask just that you use the same standard and don't use loaded phrases ("but" is a loaded word implying a reservation - your personal reservation, not a reservation that should be put forward in the voice of WP). Please also keep in mind that these are the programming languages and not the platforms (Java and .NET). The "platform support" section is already a stretch in that regard, but if it has to mean anything in an article about the programming languages it must be that you can use the language to code for the platform. That's why Android has a "yes". Just use the same standard for C#. If you believe that the way through which a platform is supported is important then put it in a note - like {{yes}}<ref>through Mono</ref> and {{yes}}<ref>through Dalvik</ref> - or something to that effect (with links). That way WP does not make judgement calls but allows the reader to come to his/her own conclusions. Useerup (talk) 11:57, 26 November 2012 (UTC)
Then change the column value for Android support on Java. I don't oppose doing so whatsoever, I just am not aware of Java support on Android. You seem to assume that I am pro-Java and am attempting to attack C#, but I actually prefer to use C# over Java, so your argument is unfounded. If the word "but" bothers you then "using" may be used, thus it may read: "Yes, using third-party software". You seem to be offended at the fact that these languages require third-party software to run on other platforms and are attempting to hide this fact, but this information is useful to the reader and is very relevant to the topic of platform support. Kupraios (talk) 17:39, 26 November 2012 (UTC)
WP:AGF. I reverted your edit and in the very summary I pointed out how it would be unbalanced to not use the same standard for Java. You were actually the one accusing me of favoritism towards C#, so let's not go there. And yes, I do have a problem with "but" because it is a value judgement. Some may even believe that it is a "good thing" that it's 3rd party support. Rather than saying "3rd party" why not just point out how in a ref? For the record, I do believe that the entire section is problematic because you can always find some way to use a programming language for a given platform through cross compilation. It is meaningless when comparing languages. It was put there by someone who mistook language for platform. I would prefer we just delete the section. Useerup (talk) 18:07, 26 November 2012 (UTC)
I tried to work in the specific references. Is that better? I have reservations about the in-the-box link. I'm not convinced that you can actually run Java on a non-jailbroken iOS device. in-the-box does not seem to be a cross compiler, but rather a VM. Apple does *not* allow VMs on iOS devices. Also, there's a blog post ref in there. Useerup (talk) 18:22, 26 November 2012 (UTC) In-the-box seems to be dead, is undocumented, there is no evidence that it can be used to create App Store compliant apps, and in any case it would not allow you to code to the iOS SDK, severely limiting its usefulness.
I'd argue to keep it in because although it is true that the programming language itself is separate to the platform with which it runs on, this information conforms to what people would expect to find in this article. We have to find a balance between political correctness and usefulness. People reading the article will infer that it is the native platform being referred to, otherwise they most likely don't understand the rest of the article. Also, what about running virtual machines on an OS? Should we take those into consideration too? I think not, it's best we just assume native support as a default. Otherwise the articles regarding software made to run on a specific OS could be argued as being able to run on all OSs even though that isn't exactly true.
The changes you've made are better in that it is clearer that there is no native support on those platforms, but I wouldn't put specifics (referring to Mono) the way you have. I would just refer to it as third-party and have a reference to Mono because otherwise it could suggest favouritism towards using Mono and not some other software that could exist (if it does). It suggests that Mono is an officially used platform for running C# rather than a community project. It's best to just be generic and have the reference be specific, hence: "Yes, using third-party software<ref>Mono</ref>". That way more references can be added in the future without disrupting the visual appeal of the table, and also it contains more information in a smaller space. Kupraios (talk) 21:12, 26 November 2012 (UTC)
As for Android, it is called Java but it is really not Java as defined in this article. A lot of Java base library is different on Android, or works differently, and Android has stalled to part of Java 6, meaning that all Java 7 evolutions of the language are not supported. Hervegirod (talk) 09:27, 20 December 2012 (UTC)

Speed/performance comparison

Microsoft bans benchmarking .NET Framework without their written permission: Microsoft .NET Framework Benchmark Testing Terms. And Mono is not the official .NET implementation to compare with Oracle Java. That's why adding speed/performance comparison to this article is not correct. So, based on above facts remove this section, please.69.18.50.2 (talk) 10:07, 2 December 2012 (UTC) cs_student

I still think performance would be an aspect readers would find relevant. I agree that the section as it stands now is misleading. We could remove it, but we could also try to work in the caveats you mention. Would you care to try? Useerup (talk) 11:29, 2 December 2012 (UTC)
The only implementation where its allowed to benchmark results for C# is Mono. Yet C# is shown supported on a variety of platforms in this article because of Mono. Plus the paragraph (at least now) shows clearly that the comparison is made with Mono. I don't know why it should be removed. Hervegirod (talk) 09:31, 20 December 2012 (UTC)
As I wrote, I absolutely believe the issue is relevant. There are some (very) old perf tests showing that .NET is faster than Java on Windows. They are dated and are probably not representative of the current state, and I'm not comfortable mentioning that in the paragraph. I would prefer that the article explain that there very well could be differences between the 1st party implementation and Mono but that there's no comparison data available because of the licensing terms. Useerup (talk) 12:11, 20 December 2012 (UTC)
A contractual ban on benchmark publishing seems like an antitrust violation that Microsoft could easily use to ensure that the only benchmarks that get published are ones that favor the .NET framework. That said, we have no reason to submit to their will. 68.173.113.106 (talk) 20:50, 21 July 2013 (UTC)

I updated this section to match the current link, Microsoft has changed their position on benchmarking should someone want to try to find references, seems they are mostly comparable from what I can tell.


5/24/2013: I removed this sectionEvolvedmicrobe (talk) 21:18, 24 May 2013 (UTC). Although I believe this is HIGHLY relevant to a comparison between the two and would love to see someone put it back in with a more thought out section. I thought it suffered from the following problems.

1 - The style and content of the opening paragraph was not up to par. This statement came off as pretty vacuous: "Comparing language speed is tricky. It depends on the virtual machine and the environment used. It can also depend on whether the benchmark code was written in an idiomatic or an optimised style."

2 - The benchmark tests given are not useful. Java and C# are such similar languages that it should have been possible to directly compare them by essentially writing the same program line for line. However the algorithms/code used in these benchmarks differs substantially (for example, encoding things as bytes versus unicode characters, writing multi-threaded versus single threaded applications, optimization switches, etc.). The largest difference between Mono/Java (Binary trees test) is entirely an artifact of mono being run with an outdated version of the garbage collector, and the more common microsoft implementation shows essentially no difference at all for that test.

I would love to see a more rigourous section developed here. This article: http://www.itu.dk/~sestoft/papers/numericperformance.pdf seems like it could be a good start, though it only focuses on numeric computations, and it seems comparing garbage collectors, native interopt, memory usage, etc. would all be important.

Unless the article can say something meaningful, well supported, and useful, I think this section should remain out. — Preceding unsigned comment added by Evolvedmicrobe (talkcontribs) 21:15, 24 May 2013 (UTC)

Addendum: Just noticed the article title says it is only comparing Microsoft to Oracle, I think we should expand that to Mono and IBM so we can add this performance section. — Preceding unsigned comment added by Evolvedmicrobe (talkcontribs) 21:44, 24 May 2013 (UTC)

Reference Type - Delete Phantom Reference Discussion?

I think there is a section that needs to be deleted, but am worried I have missed something so wanted to ask for comments before doing so.

The section on reference types contains this sentence:

" Soft references are much like weak references, but the JVM will not deallocate softly-referenced objects until the memory is actually needed."

But the cardinal rule of garbage collection (at least as I understand R/C#/Java) is that memory is only de-allocated/garbage-collected when memory is needed, never before. As such, I don't understand the distinction from a weak reference, and think the table should be condensed.

Anyone object (or see the error?)

Cheers, N Evolvedmicrobe (talk) 04:28, 1 November 2013 (UTC)

Arbitrary size decimals

C# offers BigInteger that fits the description. Consider changing "no" to "yes" — Preceding unsigned comment added by 176.195.178.252 (talk) 04:15, 3 May 2014 (UTC)

C# already has a "yes" for arbitrary size integers (which is BigInt). Java has both arbitrary integers and arbitrary size decimal numbers. Do you feel this should be clarified? Useerup (talk) 13:14, 3 May 2014 (UTC)
Oops, you're right, I messed up those two. No need for clarification, I just need to be more attentive. — Preceding unsigned comment added by 95.220.90.101 (talk) 17:57, 3 May 2014 (UTC)

"Summarized differences" hardly a summary...

The first section #Summarized differences is toooo long. Can we make it a lot shorter or split it up into multiple sections? I've critiqued this page before, as an IP. Qzekrom (talk) 01:53, 27 October 2014 (UTC)

Improved and refactored into better structured sections. -- Softzen (talk) 01:58, 24 February 2015 (UTC)

Section Language history and evoluton deleted

The previous issue list by other editors:

[relevant?]

The section has been removed, because much of its information is subjective, superfluous, and duplicated elsewhere, e.g. in the C Sharp and Java main articles. -- Softzen (talk) 03:53, 24 February 2015 (UTC)

Language history and evolution -outright bias

This section is terrible, and terribly unencylopedic. Java comes off as the George Orwell "Animal Farm" of computing, while C# sounds like the tyrant with operational efficiency. I think framing the historical perspective is very important, but it comes off so biased I think deleting it entirely would add to the article. An alternative would be to cut any post-2000 (the debut of C#) reference from the article. Would anyone be opposed to this? Evolvedmicrobe (talk) 04:40, 1 November 2013 (UTC)

I'm a little tired of seeing accusations of 'bias' here; as far as I can see, the Java section is just sloppy, and the claims made there can be substantiated with references or deleted. However it would be good to avoid creating complete version histories of both and refer to Java version history, Java (software_platform)#History, C Sharp (programming_language)#History, and .NET Framework version history for details instead. Rp (talk) 10:16, 1 November 2013 (UTC)

Agreed! 132.183.101.106 (talk) 22:04, 1 November 2013 (UTC)

Agree, the section is removed. -- Softzen (talk) 04:09, 24 February 2015 (UTC)

Page Is Irrelevent

Is Wikipedia in the business of providing competing product comparisons?

These are two proprietary products produced by competing corporations. The features in both products are subject to change based on the owners goals and marketing decisions without public input. Thus many of the details are volitile and the article will quickly go stale. There are already inaccuracies on both sides of the comparison some due to the age of the article and others intended to skew the article.

The features comparison colors the yes and no values green and red respectively. This is an immediate value judgement on the included of featues. Due to this red/green coloring a minority of the tables of features have more red boxes on the C# side than the Java side. A simple glance at this bias reveals an immediate inference that C# is better than Java, despite many of the features that are not in Java are conscious design decision by Sun/Oracle.

It could be said that Microsoft has taken a kitchen sink approach to language design while Sun/Oracle has taken a more measured approach to feature inclusion. This is implied by the discussion about keyword growth in Java vs C#. So, as a common comparing any two languages in computer science, feature count and quality of features are not relevent to language utility, inferiority, or superiority. Thus the red/green coloring is misleading and at times innaccurate.

Finally, the code samples are also misleading. All the code samples as displayed have a greater line count for Java than the 'equivelent' C# implying Java is more verbose. In the article this is true for multiple reasons. The algorithms are different. In the Input/output section the Java example uses buffered IO while the C# sample does not. The Java implementation uses a superfluous File object constructor on both input and output which is not necessary (Constuctors for FileReader and FileWriter exist with a String argument for a file path like C#). Also to make the IO buffered in the C# example would need a call to a BufferedReader and BufferedWriter constructor to bring the number of constructor calls between the two samples equal.

Similarly, the "Pass by Reference" uses style to increase the line count Java sample. First: The swap method adds a line of whitespace after the temporary variable initialization. Second: A three line comment is added above the main method in the Java example. Third: the output line at the end of the main method is split into two lines in the Java example while being syntactically identical. Finally, even more damning the example is chosen to show the differences in C# and Java while casting the Java in a bad light because it "still" has not changed the value of s. Another equally simple example can be chosen where C# does not produce the results expected.

These are just two of the examples of how code that is contended to be "equal" is used to show disadvantages in Java. There are more.

This page should be scrapped and not rewriten for the reasons stated at the top. If not scrapped is should be rewritten to remove biases noted above.

One last note, I make my living writing C# code.

The views expressed in this article are solely the views of the author and not the owner of this IP address.

Seconded - this entire article is clearly VERY biased. EboMike (talk) 20:53, 2 March 2013 (UTC)
Thirded... While something like this could be useful (and it actually did answer a question I was looking up), it is in no way encyclopedic in nature. Something like this belongs on a tech advice site like stackoverflow, not wikipedia. Potatman (talk) 16:50, 15 March 2013 (UTC)
Fourthed. It's an unbalanced article, and it appears to be not consistent about trying to compare contemporaneous language specifications, a clear indication of poor research. (It doesn't belong on StackOverflow though; it would be rapidly closed as flamebait.) It's a shame, as a balanced comparison would be a genuinely useful thing, but I get the impression that most people preferring one or the other regard the trade-offs they are making as reasonable (assuming they don't go for outright language partisan fanboyism foolishness). Unfortunately, the proportion of academic — i.e., properly peer reviewed — references used is very small; having more independent voices describing the differences would be helpful here because of the languages' shared history. Or the core language designers from either side; I doubt they'd indulge in the sort of poor scholarship displayed here. 82.42.214.208 (talk) 01:04, 3 October 2013 (UTC)
My problem with it is that it's full of defensive-sounding language that contributes nothing to the comparison of language features. Things like "Java does not permit pointers or pointer-arithmetic within the Java runtime environment. The Java language designers reasoned that pointers were one of the primary features that enable programmers to inject bugs into their code and chose not to support them." Everything after the first sentence is just someone's attempt to editorialize using the designers' "intent." There is nothing about stating the features of the language that implies a shortcoming, and they have no business in this article.94.135.236.132 (talk) 13:51, 12 March 2015 (UTC)

I found it very informative though, and filled with useful information — Preceding unsigned comment added by 132.183.102.105 (talk) 23:43, 12 March 2013 (UTC)

Sure, it may have information in it, but that doesn't change the fact that it is not suitable for Wikipedia in its current form. EboMike (talk) 02:04, 22 March 2013 (UTC)


Page is very useful - An encylopedia at best is a source of useful knowledge, this page contains a great deal of useful information. In response to arguments that this is irrelevant:

  • These are two proprietary products produced by competing corporations.

Ignoring how C# and Java are open standards, why would this matter? If there was an article on advertising strategies of Coca-Cola and Pepsi it would still be interesting and useful.

  • Many of the details are volitile (sic) and the article will quickly go stale.

That what we know changes is not a reason to never teach. What is the current status of hormone replacement therapy? How about dietary recommendations of sodium levels?

  • Other issues related to colors and verbosity

Someone cleaned these up "try {" in Java versus "try\n\t{" in C#. Variable usage of white space is irrelevant, the reader will know that, ditto with colors.

  • Bias

If information is incorrect or presented in a poor fashion, it should be removed. This is an entirely separate issue. Why in the "Pass by reference" only immutable and basic types are used? String in Java is well known to be immutable while StringBuffer is the corresponding mutable class, in this case it seems that in java all the values are passed by reference. 194.127.8.25 (talk) 13:31, 4 October 2013 (UTC)Marco (talk) 15:04, 4 October 2013 (UTC)

  • Not Encyclopedic

Admittedly, Britannica probably would not have this article. Britannica is also not as good as wikipedia. This article is a compendium recommending a lot of good information. People need to get things done with computers, C/Java/Python/C++/C#/Haskell are all ways to get stuff done, how do they compare? Many people have found this article useful. — Preceding unsigned comment added by Evolvedmicrobe (talkcontribs) 21:42, 24 May 2013 (UTC)

Agree, the article is definitely useful and valuable, for programmers and practitioners from both camps who are interested at the differences and connections between the two popular languages. Keep and improve it. -- Softzen (talk) 02:10, 24 February 2015 (UTC)
Err... Java is an open standard. 68.173.113.106 (talk) 21:01, 21 July 2013 (UTC) (woops, sorry! I thought it was but the oracle google lawsuit made me wonder.
I agree there really is no point to having articles like this at all. This is something that makes sense for a Gartner or Forrester report but not an encyclopedia. MadScientistX11 (talk) 21:02, 17 December 2013 (UTC)

External links modified

Hello fellow Wikipedians,

I have just added archive links to one external link on Comparison of C Sharp and Java. Please take a moment to review my edit. If necessary, add {{cbignore}} after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}} to keep me off the page altogether. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true to let others know.

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—cyberbot IITalk to my owner:Online 18:30, 7 January 2016 (UTC)

External links modified

Hello fellow Wikipedians,

I have just added archive links to 2 external links on Comparison of C Sharp and Java. Please take a moment to review my edit. If necessary, add {{cbignore}} after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}} to keep me off the page altogether. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at {{Sourcecheck}}).

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—cyberbot IITalk to my owner:Online 14:54, 28 February 2016 (UTC)

Boxing/Unboxing

The following statement in the text seems inaccurate:

   In C#, the primitive types are subtypes of the Object type.

The C# MSDN Reference Documentation from Microsoft says this about primitive types:

   Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type. When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap. Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit. The concept of boxing and unboxing underlies the C# unified view of the type system in which a value of any type can be treated as an object. 

Which is available at this link: https://msdn.microsoft.com/en-us/library/yz2be5wk.aspx — Preceding unsigned comment added by 71.66.101.171 (talk) 01:57, 10 August 2016 (UTC)