r/programming • • Mar 09 '16

var keyword proposed for Java

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

395 comments sorted by

View all comments

Show parent comments

10

u/lamarf Mar 09 '16

You're not always going to be looking at code through an IDE, though (i.e. if I'm looking at a code review on GitHib, which honestly makes up a lot of my time spent), and for large projects, the indexing that makes that happen can be painfully slow and sluggish to use (I'm looking at you, Eclipse). And either way, it's always going to be better for readability if the information I need is right there on the screen for you, not hidden behind clicks and interaction with the IDE.

4

u/FMAlfonse Mar 09 '16

I have been of the opinion in c++, that if the type isn't obvious then you shouldn't use auto. That doesn't mean auto isn't useful iterators are horrible to write, using auto it = myVector.begin(); makes it alot more pleasant to both read and write. However I would use std::string result = aClass->someFunc(); Best of both worlds but getting people to adhere to it can be a nightmare.

1

u/immibis Mar 10 '16

I have been of the opinion in c++, that if the type isn't obvious then you shouldn't use auto.

Unfortunately, the person whose code you're trying to read does not have that opinion.

6

u/kqr Mar 10 '16

"But you can use it to write bad code" is always the argument against introducing a language feature. It doesn't matter which feature. Someone will say it's a bad idea because you can write bad code with it.

Guess what? You can do that with any feature. It's a bad argument.

2

u/immibis Mar 10 '16

"It encourages bad code" is a reason against introducing a language feature. Even for things that are controversially bad (i.e. not everyone agrees they're bad).

See some of the other comments on this very post.

3

u/kqr Mar 10 '16

Sure, that's a better argument. I guess we disagree on the degree to which local type inference encourages bad code.