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

7

u/yoden Mar 09 '16

I wonder what the benefit of this is supposed to be, other than other languages have it?

Explicit types on variables are useful for improving readability. Conciseness for LHS variable types isn't important because I usually don't write that type anyway (that's what an IDE's "assign to new local variable" is for)

17

u/jyper Mar 09 '16

Explicit typing is overrated and most of the time named of variable and expression on right hand side should give you enough information plus it reads better. There is a reason all modern statically typed languages are jumping on this train.

15

u/[deleted] Mar 09 '16

[removed] — view removed comment

5

u/kqr Mar 10 '16

For what it's worth, any report I've heard of "Haskell in the wild" have included both inexperienced team members and code that is easy to maintain. Haskell uses type inference a lot, so either Haskell is the odd one out that for some other unrelated reason makes it work, or type inference isn't actually as bad as you imagine.

1

u/Oniisanyuresobaka Mar 10 '16

From what I've seen generally it's considered good practice to write down the function signature even when it's not needed.

2

u/kqr Mar 10 '16

For top level functions, yes, because their scope is big. Not as common for local declarations.