Java 5.0 vs C# 3.0 Shootout
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
- No Type Erasure in C # , new T() anyone ??
- Value types like int or Enumeration can be be used as type parameter so MyClass<int> is perfectly valid.
- No Wildcards in C# which I terribly miss , Cast<>() from Linq Enumerable doesnt look too pretty
- Java has better support for covariant and contravariant for type parameters , I dearly miss ” ? ” from java.
- Assignment Type inference works in Java but not C#
public T <T> myMethod()
T var = myMethod() ; // T is inferred here !!!
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
Both of which can be done in java side ..Ok so this round goes to Java
Round 3 : IDE’s
This round is a TIE..
Round 4 : Packaging
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..
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 ..
This Round goes to Java
Filed under: Uncategorized | 1 Comment