Search code examples
c#javaprogramming-languageslanguage-features

What features should Java 7 onwards have to encourage switching from C#?


C# has a good momentum at the moment. What are the features that you would need to have in order to switch (or return) to Java?

It would also be quite useful if people posted workarounds for these for the current Java versions, e.g. Nullables being wrapped around custom classes, to make this a much more interesting wiki.


Solution

  • As a .NET/C# developer here are the missing features that annoy me. This list in no particular order - just as thoughts come to mind:

    1. The Java library is too small. For common things I have to choose between 5 competing open source products because the base library is lacking in so many ways.
    2. This is an Object Oriented programming language right? Why in the heck do primitive types not inherit from "object"?
    3. Pointers
    4. Lambdas
    5. Closures
    6. Partial Classes and to a lesser extent partial Methods
    7. Real support for Generics
    8. Using statements and Dispose - this was a real WTF for me. You really have to explicitly close connections in try/catch blocks. Poor Java guys!
    9. Yield return would be nice
    10. Unsigned integers - again WTF? I have to use number types larger than I need for what purpose again?
    11. In Java you can return from final blocks of try/catch. A co-worker confused the hell out of me for hours by introducing a bug this way. This behavior should be prohibited as in C#.

    I rarely have to use Java and when I do, I have all sorts of WTF moments.

    Edit: I Removed for-each comment based on the fact it is no longer a missing Java feature since 1.5.