StudioFortress {l Wrote}:...for local variables, I don't see why this couldn't be added, without remaining backwards compatible. Again, it's just allowing you to make your code a bit more terse and easier to refactor.
I was trying to find an answer to this I only found two reasons; one of them I wasn't satisfied with because the answer was incomplete. The first answer is that it's not as simple as adding new tokens and semantics, but also adding new restrictions to the type checker that would end up breaking legacy code. I wasn't satisfied with this answer because I didn't see enough good examples supporting it. This also might have to do with why they chose to pursue type inferencing on the right-hand sign of statements (with the diamond <> operator) instead of the left-hand sign, like they do now in C#. The second answer I found is that they recommend the type checker be heuristic-based so that it runs faster. That makes sense if you're making your own language targeting the JVM like Scala or Groovy or AspectJ or Velocity, since you probably need to write a type checker for it anyways and you can make it as advanced as you want to.
StudioFortress {l Wrote}:I meant if the developer changed the code from 'HashMap' to 'ArrayList', they would have to update this in (at least) two places, rather then just one.
I don't even know what you mean by this example because HashMap and ArrayList don't share a common interface in java.util.*; ArrayList is not even a type of Map. It's not like you can treat a Map as a List in the rest of your code anyways because they don't even share a common interface in any package, so if that's what your goal was and if this was possible, then you wouldn't be able to call any methods from your variable in the first place.
If you're looking to, say, replace HashMap with something else that implements Map such as TreeMap, then that's what dependency injection techniques like factory method pattern and frameworks are for. Hardcoding your dependencies into your classes using the new keyword (static binding) is generally considered to be a bad thing anyways, and the way around it is to use dependency injection. Binding dependencies is then done during run-time (dynamic binding), unless you're using GWT which does this during compile time (deferred binding).
Crossfire and Wesnoth played a game of chess. It started out as an open game.