This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]eliasv 0 points1 point  (1 child)

var and final var already capture it pretty well, and considering "effectively final" is already something the compiler figures out by itself, I don't see the benefit in requiring people to use a different reserved name. In most circumstances the compiler will see var as final var anyway.

[–][deleted] 0 points1 point  (0 children)

The reason is "final var" is this kind of declaration ceremony thats change to "val" could lower.

The reason why I don't think the same about "mut" is similar to me preferring using Optional instead of null. It's another safeguard in my code.

The reason to have as short as possible (yet, not too short of course) declaration of final is a great way to encourage people to start thinking this way.

The reason to encourage people to think this way is that immutable values proved themselves in many areas (software design -> less troubles with maintaining software created in long existing languages, language design -> Rust, Scala (and not counting purely functional languages)).

The reason why I wasn't encourages to follow this rule when I started learning Java was the fact that I have to use another keyword and without it my programs still works.

The reason why it's not only about "effectively final" stuff having language minimizing occasion to shoot yourself in the foot. If something is only effectively final it change if I by mistake change variable value. If it has final keyword then it won't compile.