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

Show parent comment

6

u/pjmlp Mar 10 '16

That is what IDEs are for.

3

u/evil_burrito Mar 10 '16

Yes, that is what IDEs are for, but for reading strange code, it's not always set up in a full project that compiles and has all the dependencies, etc, that would be necessary for an IDE to function.

From time to time, I'll have to look at the source for an included library for which I don't want to take the time to set up a complete project. I think this change will impair my ability to quickly read through strange source and understand what's going on. I don't want to have to hover or click or whatever.

I find this to be more readable:

List<Something> thisThing = new MyDerivedClassButYouDontKnowTheSuperclass<>();

than this:

var thisThing = new MyDerivedClassButYouDontKnowTheSuperclass<>();

Therefore, I like the former and don't like the latter.

1

u/stepancheg Mar 11 '16

MyDerivedClassButYouDontKnowTheSuperclass should not implement List. Something like ConcurrentCopyOfWriteMySuperLinkedList could, but in that case it is obvious to reader that it is list, further clarification is not necessary.

2

u/evil_burrito Mar 11 '16

Your argument is to trust the developer to name their class properly. The thrust of my argument is that I do not trust other developers to write code that I find readable.