Re:Representing the Impractical and Impossible with JDK 10 “...
by vbezhenar on Sunday March 04, 2018 @03:15PM
(#16516429)
I'm very disappointed that they didn't make `val` keyword. Very simple change but code becomes significantly more readable and a lot of bugs will be compile errors.
[ Parent
| on HN ]
Re:Representing the Impractical and Impossible with JDK 10 “...
by threeseed on Sunday March 04, 2018 @05:30PM
(#16517187)
Java is not Scala though.
By default everything has always been mutable e.g. collections, variables. And so whilst I support val I can appreciate the difficulty in switching everyone to an immutable by default mindset. Especially given the lack of decent functional transforms e.g. map, flatMap, filter in Java.
Re:Representing the Impractical and Impossible with JDK 10 “...
by kochthesecond on Monday March 05, 2018 @04:00AM
(#16519701)
I am also disappointed by this, I want it to be more painful to use rebindable references than final (immutable) references.
Re:Representing the Impractical and Impossible with JDK 10 “...
by saagarjha on Sunday March 04, 2018 @03:47PM
(#16516622)
How so?
Re:Representing the Impractical and Impossible with JDK 10 “...
by rbonvall on Sunday March 04, 2018 @04:03PM
(#16516703)
I'm sure he means `val` as in Scala, where it is used to define a name that cannot be rebound:
val x = 1
var y = 2
x = 3 // compile error
y = 4 // ok
It makes it easier to read code since you don't have to keep track of changes in your head.
Re:Representing the Impractical and Impossible with JDK 10 “...
by saagarjha on Sunday March 04, 2018 @04:13PM
(#16516777)
Yes, this would be a nice addition, but I think final var might be able to stand in for it as of right now. One issue if it was adopted might be that “final” in Java doesn’t actually mean a whole lot, since there aren’t a lot of value types where mutation can be detected.
Re:Representing the Impractical and Impossible with JDK 10 “...
by blattimwind on Sunday March 04, 2018 @04:40PM
(#16516931)
Or as in Kotlin.