book icon indicating copy to clipboard operation
book copied to clipboard

[im]mutable variable vs [im]mutable value

Open tomaszdrozdz opened this issue 2 years ago • 1 comments

It would be nice to add few simple words explaining distinction between:
- immutable/mutable variable
- and immutable/mutable (fixed size known at compile time/ unknown at compile time size ) value.
That can have educational value for someone not having lots of insight into programming concepts before, as well as would clarify things more for them.

I also wonder if only string literals are build into binary, or maybe any literal like integer literal ?

I also wonder if reference/slice is immutable - it seams to me so but wish to read it from the book :)

tomaszdrozdz avatar Apr 04 '23 11:04 tomaszdrozdz

I would go even further. This caught my eye today (chapter 3.1):

Although variables are immutable by default, you can make them mutable by adding mut […]

Rust tries to cut down the legacy complications of learning programming. Part of this is language design, part of it is use of terms. I would prefer a manual (and culture) where constants are never called ”variables”.

What would be better text, then? My primary instinct went for “values” but it’s not about the values, it’s about the entity carrying the value. Const is the standard name.

Is this a problem worth tackling, do you have ideas?

akauppi avatar Dec 12 '23 06:12 akauppi

Thanks for the note! A couple comments here:

  1. While the book aims to be a good introduction to Rust, it is not at all aiming to be a good introduction to programming. (I think it would be interesting to see an introductory programming text which used Rust, but it would also be relatively challenging!)

  2. The other questions and comments raised here, while interesting, are not things we want to take page count on. (Remember: this all ultimately ends up in print, and it is already a very large physical book!)

  3. To @akauppi’s suggestion: precisely because the book needs to work as a primary way people who already know other programming languages learn Rust, we try to use standard terminology as much as possible to avoid having to constantly explain how Rust’s terminology differs from everything else. Moreover, the variables in Rust are variables.

Hopefully that makes sense! I am going to go ahead and close this. Appreciate the feedback, though!

chriskrycho avatar Apr 05 '24 18:04 chriskrycho