Here are some points why I do not think "let" or "val" as aliases for "final var" in Groovy would be a good choice:

1. val does of course look very similar to var, which is exactly the
   kind of confusion one wants to avoid when designing a language syntax.
    1. Scala and Kotlin using it are imho not good points: Syntax
       (besides compile time, too lenient operator overloading, ...) to
       me is one of the major shortcomings of Scala in general. Kotlin
       is very similar to Groovy, but everywhere it added syntax, its
       choices have been, again in my opinion, questionable, and it
       suffers from keyworderitis in general.
2. "val" to me implies a value type, i.e. an immutable data structure,
   which is exactly what "final" is not about (instead it implies an
   immutable pointer to an object, which might be mutable, immutable,
   or a mix of both), unless it is applied to the handful of
   fundamental data types.
3. "let" does not imply any kind of final-ity to me, it just reminds me
   of how bad the syntax of BASIC was, where it also did not imply that
   a variable could not be reassigned :-)
4. JavaScript uses "let" to declare block-local variables, not final
   ones, and since this is a language many developers (have to) use,
   this might be confusing.
5. Rust uses let in an entirely different way
   (https://doc.rust-lang.org/std/keyword.let.html)

Cheers,
mg


Reply via email to