[rust-dev] "let mut" <-> "var"

Daniel Micay danielmicay at gmail.com
Wed Jan 29 19:18:42 PST 2014


On Wed, Jan 29, 2014 at 10:09 PM, Samuel Williams
<space.ship.traveller at gmail.com> wrote:
> I agree that it is syntactic salt and that the design is to discourage
> mutability. I actually appreciate that point as a programmer.
>
> w.r.t. this specific issue: I think what concerns me is that it is quite a
> high burden for new programmers (I teach COSC1xx courses to new students so
> I have some idea about the level of new programmers). For example, you need
> to know more detail about what is going on - new programmers would find that
> difficult as it is one more concept to overflow their heads.

Either way, Rust is going to warn when there is unnecessary mutability.

> Adding "var" as a keyword identically maps to new programmer's expectations
> from JavaScript. Writing a program entirely using "var" wouldn't cause any
> problems right?

Rust has block scope, so `var` would match what `let` does in JavaScript.

> But, could be optimised more (potentially) if using "let" for immutable parts.

It really doesn't introduce any potential optimizations.


More information about the Rust-dev mailing list