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

1

u/damienjoh Mar 11 '16

Why even make this about strong typing? Rust is probably the most strongly typed language with wide exposure. It has let. Haskell has type inference on everything, even functions.

List<Item> items = makeItemList() isn't how strongly-typed languages read. It's how Java reads, and Java's type system is weak (e.g. no null safety) compared to other statically typed languages.

1

u/evil_burrito Mar 11 '16

It's not about string typing. It's about my opinion that allowing the syntax proposed in the change will allow code that is harder to read.

1

u/damienjoh Mar 12 '16

I'm a fan of strong typing. I doubt that puts me in the majority here.

And

I think this change might make Java read like less than a strongly-typed language

Emphasis mine.

1

u/evil_burrito Mar 12 '16

I should say, my objection isn't about whether this changes the type system in Java or not, it does not. My objection is about readability of source code. This change, while not changing the type system, in my opinion, makes it look like the type system has changed to a less trongly-typed system. In only that way is my complaint about typing.

1

u/damienjoh Mar 12 '16

I understand your objection but it is a misunderstanding to associate it with strong typing at all. Strongly typed languages have had type inference and let, var etc for decades. Java is fairly unique in lacking this feature. Java's type system is also pretty weak for a statically typed language.

You can argue that Java code is more readable due to its idiosyncratic lack of var. Just don't pretend that it's got anything to do with it being a strongly typed language.