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

2

u/csman11 Mar 10 '16

I remember seeing an SPJ talk where he mentioned that HM cannot be used in OO languages because of subtyping (he didn't explain this). But that obviously will never happen in Java. Someone correct me if I'm wrong. I don't know a lot about type inference.

The video was something like "classes but not as you know them" on channel 9 and was about type classes. The above was briefly mentioned in the last few minutes.

Edit: title was "classes, jim, but not as we know them"

1

u/kqr Mar 10 '16

Subtyping does wreck full inference, but limited (still somewhat useful) inference is still possible. Edward Kmett once summarised it as "it works great until the point where you really need it, when it breaks down."

1

u/bjzaba Mar 10 '16

Scala can do some type inference, but it is pretty unreliable due to the presence of subtyping.