r/java • • Mar 09 '16

var keyword proposed for Java

http://openjdk.java.net/jeps/286
240 Upvotes

312 comments sorted by

View all comments

1

u/urquan Mar 10 '16

I'm not sure how I feel about type inference. It helps make small pieces of code clearer, but as the inference chain grows it becomes more and more difficult to reason about the program. You need to hold a lot of context in your mind to know the actual type at the end.

I guess the proposed use for local variables is fine, but using it for function parameters could be a real mess.

4

u/vytah Mar 10 '16

You couldn't use it for parameters. Type inference in Java-like typesystems makes it too hard, if not impossible.

1

u/[deleted] Mar 10 '16

[removed] — view removed comment

2

u/schlowmo Mar 10 '16

This is also why dynamic language stalwarts like python are ADDING optional typing to things like function parameters.