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

88

u/omair-majid Mar 09 '16

They are holding a survey on keywords (var, var/val, var/let): https://www.surveymonkey.com/r/KGPTHCG

Bikeshed away!

40

u/oscarreyes Mar 09 '16

I would love to see var / final

var   a = expr; 
final b = 1;

31

u/sudowork Mar 10 '16

Var/val from Scala is pretty reasonable as well.

7

u/kukiric Mar 10 '16

Though the one-character difference between the two keywords might cause some confusion about whether a local is final or not, and it would break existing code that uses any variables named "val" (as undescriptive as it is, it's still pretty common). "var/let" would be more reasonable for these reasons, IMO.

7

u/orclev Mar 10 '16

That's why I voted for var/let, I like that they're easier to tell apart. I feel like var/val would be just a bit too easy to typo.

1

u/kqr Mar 10 '16

Of all the concerns there, typos gotta be the smallest. A val being typoed as var will work just like you intended it to. A var typoed as val will at worst trigger a compiler error. It's really innocuous.

→ More replies (4)