Super clear. The "let" version smells a lot of "I have a CompSci PhD".
Super clear. The "let" version smells a lot of "I have a CompSci PhD".
let vs let mut is /clear/ - you can simply not mix them up.
“Let” feels like some in-joke, coming from a math via lisp heritage of “let k be any number...” to distinguish it in English from the surrounding writing. I have to guess that in early lisp (= k 5) would be an error as k isn’t defined and (k 5) errors because k isn’t a function and (let (k 5)) comes out of need for a binding function and why not “let”.
In c-like languages “k=5” is an established binding that both programmers and compilers can deal with. What does “let k=5;” add to Rust over “k=5;” ?
val => value => is immutable
Of course people are different, but this seems clear as day, assmuning very basic familiarity with functional programming?
if mutable is expensive, and should be difficult then "let mut" makes more sense.
var looks like a default to me, not a special case that needs care.
I think of it as being more math like rather than PhD.
Nothing wrong with borrowing from math.
30 years ago I think it would have reminded people more of BASIC or Fortran than (say) Scheme.
Now? It's in Javascript in its ES6 evolution and related languages, Swift, Rust, and probably other "newer" languages I'm not aware of. Scala had it ten years ago also, but is more mainstream than it was then.
Using 'var' instead of 'val' where possible: the compiler/linter will tell you this.
Or do you mean something else?