Java 5.0 vs C# 3.0 Shootout

05May08

Just a fun comparision between C# and Java ..I am obiviously not comparing stuff like LINQ, Lambda expressions which dont have java equivalents

Round 1.0 – GENERICS

  1. No Type Erasure in C # , new T() anyone ??
  2. Value types like int or Enumeration can be be used as type parameter so MyClass<int> is perfectly valid.
  3. No Wildcards in C# which I terribly miss , Cast<>() from Linq Enumerable doesnt look too pretty
  4. Java has better support for covariant and contravariant for type parameters , I dearly miss ” ? ” from java.
  5. Assignment Type inference works in Java but not C#
    in Java,
    public T <T> myMethod()
    T var = myMethod() ; // T is inferred here !!!
    in C#
    public T MyMethod<T>()
    T var = myMethod() ; // T cannot be inferred from the assignment here!!!

This round clearly goes to C# …Generics done right ( almost ..)

Round 2.0 Enums

Java has enum support too..but whats different with enums in C# is

  • They can’t define their own methods.
  • They can’t implement interfaces.

  • Both of which can be done in java side ..Ok so this round goes to Java

    Round 3 : IDE’s
    Ok ..this has nothing to do with language itself ..but most people’s ( me included ) overall experience with the language includes the IDE too ..if this was not the the factor dynamic languages would have won the battle ages ago..

  • Visual studio almost does justice to the word “Integrated” in IDE ..not more running around using 10 different tools just to put a database on the website..
  • There is no Concept of a “Power User ” in visual studio..and its still catching on to the word “refactoring” even after 15 yrs.. without resharper it would be like coding with your mouth with your hands tied behind.
    This round is a TIE..
    Round 4 : Packaging
  • C# does a pseudo OSGI with internal access modifier
  • TODO
    Round Goes to C# ..

    Round  5 : Boilerplate Code
    This is a Staticlly typed language ‘s kryptonite .. I know ..you know who is going to win this round..

  • Using blocks ..null coalescing operator , lambda expressions , Linq , automatic properties ..long list of awesome features
    Round clearly goes to C# again…no contest at all..

    Round 6 : Libraries / Frameworks

    Again this obviously has nothing to with language itself but still contributes to overall experience ..

  • Java has vast array of open source libraries to choose from ..( paradox of choice ?).. .Net libraries are mostly from Microsoft .. .Net equivalents of good stuff from JAVA like Nhibernate and Spring.NET are  generally lagging behind and receive much less attention than their java equivalents..

    This Round goes to Java

  • Advertisements


    One Response to “Java 5.0 vs C# 3.0 Shootout”

    1. I’νe learn ѕeveral excellent stuff herе.
      Ⲥertainly worth bookmarking fоr revisiting. I wonder how so much attempt you put to maкe the sort оf wonderful informative site.


    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s


    %d bloggers like this: