Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News A Comparison of C# to Java, Updated

A Comparison of C# to Java, Updated

This item in japanese

In 2001 Dare Obasanjo has written one of the most comprehensive and accurate "Comparison of Microsoft's C# Programming Language to Sun Microsystems' Java Programming Language". Now he has updated his comparison in order to reflect the changes in the current versions of both languages: Microsoft C# 2.0 and Java Standard Edition 6.

Dare Obasanjo's article is an objective comparison of the features and concepts of C# and Java. What distinguishes his work from others is that he gives a complete overview of the languages and their implementations on both platforms. Thereby his comparison also serves as a language reference and an explanation of the feature implementations as well as their pros and cons. 

The article is structured as follows:

  1. What features are the same in C# and Java?
  2. What features exist in both languages, but differ in minor manner?
  3. What concepts exist in both languages, but differ significantly?
  4. What features or concepts exist in C#, which have no counterpart in Java?
  5. What features or concepts exist in Java, which have no counterpart in C#?
  6. Conclusion

The comparison of Generics and Metadata Annotations are especially interesting, because they show and explain the apparently minor differences in the Java and C# implementation, which have some unobvious consequences when using these features in real-world projects. Another interesting aspect of the article is that Dare Obasonjo has included his conclusion from 2001 in the current version, showing the changing directions of language evolution in Java and C#:

[...] a number of features have become common across both C# and Java since 2001. These features include generics, foreach loops, enumerations, boxing, variable length parameter lists and metadata annotations. However after years of convergence it seems that C# and Java are about to go in radically different directions. The current plans for C# 3.0 are highlighted in the Language Integrated Query (LINQ) Project which encompasses integrating a number of data oriented features including query, set operations, transformations and type inferencing directly into the C# language. In combination with some of C#'s existing features like anonymous methods and nullable types, the differences between C# and Java will become more stark over the next few years in contrast to the feature convergence that has been happening over the past few years.

Dare Obasanjo's comparison offers a lot of information for developers who switch from Java to C# or vice versa as well as developers who want to get some additional information about the features and concepts of their language.

Rate this Article