Talk:Comparison of C Sharp and Java

This is an old revision of this page, as edited by Tbjablin (talk | contribs) at 04:44, 9 March 2005 (Made comment pretty). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

How does Java have a simpler language? The CLR has some JIT time optimizations as well as runtiem optimizations. Java and C# run at about the same speed really. It might not be true that Java is faster.

The article needs to be cleaned a bit... Some entries are listed as both advantages for one language and disadvantages for the other, which is at best redundant. Otherwise, it's not bad; quite complete now. GregorB 22:49, Jan 31, 2005 (UTC)

I think there is good reason for pointers to be listed as both an advantage and a disadvantage for C#. I don't think there exists enough consensus about whether pointers should be used in managed languages. It might be appropriate to go into more detail about how pointers are implemented with relative safety in C# on another page and then link it. Tbjablin 05:36, 8 Feb 2005 (UTC)

I've decided it belongs in differences after all. Tbjablin 05:44, 8 Feb 2005 (UTC)

  • Both languages allow the use of enumerations, via the enum keyword.

As far as I recall, this is false. C# uses the enum keyword, whereas Java uses a Class (link java.lang.Enum) introduced in Java 1.5. I haven't edited the page to reflect this, as I am unsure and would like confirmation first.

In Java 5.0 enums are lower case, like types, and have their own syntax.

 private enum Coin {
   penny(1), nickel(5), dime(10), quarter(25);
   Coin(int value) { this.value = value; }
   private final int value;
   public int value() { return value; }
 }

Also enums can be used in switches. Classes cannot be used this way.

 switch(menu) {
   case FILE:
     System.out.println("FILE Menu");
     break;
   case EDIT:
     System.out.println("EDIT Menu");
     break;
   case FORMAT:
     System.out.println("FORMAT Menu");
     break;
   case VIEW:
     System.out.println("VIEW Menu");
     break;

}

Check out http://java.sun.com/developer/technicalArticles/releases/j2se15langfeat/ http://zamples.com/JspExplorer/samples/jdk1_5.jsp http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

In Java even arrays are technically classes ie

   Object o = new int[10];

Further compiling:

   public class Test {
       private int enum = 10;
   }

Yields the error:

   Test.java:2: as of release 1.5, 'enum' is a keyword, and may not be used as an identifier
   (try -source 1.4 or lower to use 'enum' as an identifier)
       private int enum = 10;
                   ^
   1 error

My inclination is to call it a keyword, because of the new syntax, and the compiler error. Tbjablin 04:34, 9 Mar 2005 (UTC)