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

0

u/mk_gecko Mar 09 '16

OMG, please no!

8

u/kritzikratzi Mar 09 '16

why?

8

u/vplatt Mar 09 '16

::insert Javascript-inspired fear based response here::

8

u/stepancheg Mar 10 '16

var is JS has no type. In Java it will have type. That makes huge difference.

4

u/vplatt Mar 10 '16 edited Mar 10 '16

Yup, I know. I've used C# quite a bit, so I'm familiar with it. It does look the same as the Js keyword though, so it will require a bit of time before Java programmers stop the knee-jerk responses.

→ More replies (3)
→ More replies (4)
→ More replies (2)

3

u/irarandomdude Mar 10 '16 edited Mar 10 '16

It's responses like this that convince me that a certain percentage of Java programmers are Luddites. The same mentality as the minority who swore to never use generics and stick with JDK1.4.2 forever. Support for val and var is a great idea for Java.

2

u/asraniel Mar 10 '16

It will make code harder to read an maintain. Generics on the other hand make it easier to read code. I really dislike the idea of var in java

4

u/irarandomdude Mar 10 '16

You probably have a stronger case that generics make code harder to read (350 page generics FAQ??) than var making code hard to read. How is val sheep = new Sheep() harder to read than Sheep sheep = new Sheep() ?

1

u/asraniel Mar 12 '16

yeah thats easy.

But Val sheep = getSheep();

thats terrible, really really bad

→ More replies (2)

1

u/chambolle Mar 12 '16

C is simple language that is used a lot and has almost never been modified. C++ added a lot of things, so now we have "official guidelines" containing more than 15000 lines! https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md

What is the advantage of adding stuff which no more than syntactic sugar? Most of the IDE already gives you the type, so what ? Write a new language or use a new language if you want new things.

1

u/irarandomdude Mar 15 '16

I already do use a "new" language - Scala. I just get annoyed having to maintain old Java code and it would be great if Java caught up to other modern languages like C# etc.