C# as better Java? - No Fluff Just Stuff

C# as better Java?

Posted by: Venkat Subramaniam on June 9, 2005

Having programmed in Java and C#, I have said that C# is marginally a better
language than Java. Well, now I can claim that, at least for one reason.

I tried the following code in Java (Java 5):

public class MyClass
{
   public boolean equals(Object obj)
   {
      return super.equals(obj);
   }
}

It compiled with no error or warning.

I tried similar code in C#.

public class MyClass
{
   public override bool Equals(object obj)
   {
      return base.Equals (obj);
   }
}

You will get a warning (actually I got an error since I Treat Warnings as Error ? see Gotcha #12).

warning CS0659: 'TestApp.MyClass' overrides Object.Equals(object o) but does not override Object.GetHashCode()

>

I am glad to see that the C# compiler creators have followed Joshua Bloch?s recommendation (Item #8) in
Effective Java Programming Langauge Guide.

Venkat Subramaniam

About Venkat Subramaniam

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, and an instructional professor at the University of Houston.

He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.

Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at agiledeveloper.com. You can reach him by email at venkats@agiledeveloper.com or on twitter at @venkat_s.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »