Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 969
NT_ Avatar asked Oct 20 '09 14:10

NT_


People also ask

In what C# is better than Java?

C# is generally considered faster than Java, although the difference is insignificant. Both languages are compiled, but C# uses a just-in-time compiler while Java uses an ahead-of-time compiler. This means that C# code is typically executed more quickly.

Why is C sharp so similar to Java?

C# and Java are similar languages that are typed statically, strongly, and manifestly. Both are object-oriented, and designed with semi-interpretation or runtime just-in-time compilation, and both are curly brace languages, like C and C++.


1 Answers

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.

like image 161
5 revs Avatar answered Sep 29 '22 20:09

5 revs