Re: [rust-dev] let mut - var

2014-01-30 Thread Steven Fackler
The Zen of Python also says There should be one-- and preferably only one --obvious way to do it. Steven Fackler On Thu, Jan 30, 2014 at 11:35 AM, Donaldo Fastoso donquest...@rocketmail.com wrote: I like python's rational of consenting adults: Give people the tools to do the right thing, if

Re: [rust-dev] let mut - var

2014-01-30 Thread Jason Fager
3 extra characters isn't doing anything to stop consenting adults. Nobody's saying get rid of mutable variables, just that it seems like a waste of limited resources to figure out how to streamline them when in general their use should be limited to where necessary. Python isn't busy trying to

Re: [rust-dev] let mut - var

2014-01-30 Thread Lee Braiden
On 30/01/14 17:18, Jason Fager wrote: 3 extra characters isn't doing anything to stop consenting adults. Nobody's saying get rid of mutable variables, just that it seems like a waste of limited resources to figure out how to streamline them when in general their use should be limited to where

Re: [rust-dev] let mut - var

2014-01-30 Thread Brian Anderson
I'm convinced by this thread that this issue should be put to bed forever. I added a note to the design faq issue: https://github.com/mozilla/rust/issues/4047#issuecomment-33751021 On 01/30/2014 03:20 PM, Benjamin Striegel wrote: https://github.com/mozilla/rust/issues/2643 I came here to

Re: [rust-dev] let mut - var

2014-01-29 Thread Patrick Walton
On 1/29/14 6:34 PM, Samuel Williams wrote: Perhaps this has been considered already, but when I'm reading rust code let mut just seems to stick out all over the place. Why not add a var keyword that does the same thing? I think there are lots of good and bad reasons to do this or not do it, but

Re: [rust-dev] let mut - var

2014-01-29 Thread Brian Anderson
On 01/29/2014 06:35 PM, Patrick Walton wrote: On 1/29/14 6:34 PM, Samuel Williams wrote: Perhaps this has been considered already, but when I'm reading rust code let mut just seems to stick out all over the place. Why not add a var keyword that does the same thing? I think there are lots of

Re: [rust-dev] let mut - var

2014-01-29 Thread Kevin Ballard
On Jan 29, 2014, at 6:43 PM, Brian Anderson bander...@mozilla.com wrote: On 01/29/2014 06:35 PM, Patrick Walton wrote: On 1/29/14 6:34 PM, Samuel Williams wrote: Perhaps this has been considered already, but when I'm reading rust code let mut just seems to stick out all over the place. Why

Re: [rust-dev] let mut - var

2014-01-29 Thread Sean McArthur
Part of the nice thing about `let mut` is that it requires you to opt-in to mutability, making it a conscious choice. Having `let` and `var` would make Rust be like ES6: we all look at `let` and say why bother. For Rust, I imagine many would get into the habit of using `var` over `let` because

Re: [rust-dev] let mut - var

2014-01-29 Thread Matthew McPherrin
let mut is to some degree syntactic salt, in my mind. Minimizing mutability as the easy thing to do creates better code, I think. That isn't to say mutability is a bad thing, but more that you should think about whether you need it when you're writing code. I'm not convinced the incremental

Re: [rust-dev] let mut - var

2014-01-29 Thread Samuel Williams
I guess the main gain would be less typing of what seems to be a reasonably common sequence, and the formalisation of a particular semantic pattern which makes it easier to recognise the code when you visually scanning it. On 30 January 2014 15:50, Kevin Ballard ke...@sb.org wrote: On Jan 29,

Re: [rust-dev] let mut - var

2014-01-29 Thread Daniel Micay
On Wed, Jan 29, 2014 at 9:52 PM, Sean McArthur smcart...@mozilla.com wrote: Part of the nice thing about `let mut` is that it requires you to opt-in to mutability, making it a conscious choice. Having `let` and `var` would make Rust be like ES6: we all look at `let` and say why bother. For

Re: [rust-dev] let mut - var

2014-01-29 Thread Corey Richardson
Last I did a survey, `let mut` was less than half (and more around 30-40%) of the `lets` I found, though it wasn't exhaustive. It's also important to note that Rust is not a language suited for new programmers. Far too many concerns; it tackles hard problems and makes tradeoffs that new

Re: [rust-dev] let mut - var

2014-01-29 Thread Huon Wilson
On 30/01/14 14:09, Samuel Williams 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

Re: [rust-dev] let mut - var

2014-01-29 Thread Samuel Williams
Do you think for client code it would be the same proportion as in library code? On 30 January 2014 16:13, Huon Wilson dbau...@gmail.com wrote: On 30/01/14 14:09, Samuel Williams wrote: I agree that it is syntactic salt and that the design is to discourage mutability. I actually appreciate

Re: [rust-dev] let mut - var

2014-01-29 Thread Samuel Williams
What about constant folding? Surely let mut x = 10 is easier for the compiler to optimise? On 30 January 2014 16:18, Daniel Micay danielmi...@gmail.com wrote: On Wed, Jan 29, 2014 at 10:09 PM, Samuel Williams space.ship.travel...@gmail.com wrote: I agree that it is syntactic salt and that

Re: [rust-dev] let mut - var

2014-01-29 Thread Patrick Walton
On 1/29/14 7:20 PM, Samuel Williams wrote: What about constant folding? Surely let mut x = 10 is easier for the compiler to optimise? In less advanced compilers, that may be true. But Rust internally converts everything to SSA, so there is no difference. Patrick

Re: [rust-dev] let mut - var

2014-01-29 Thread Daniel Micay
On Wed, Jan 29, 2014 at 10:20 PM, Samuel Williams space.ship.travel...@gmail.com wrote: What about constant folding? Surely let mut x = 10 is easier for the compiler to optimise? Rust can warn with 100% accuracy if a variable is unnecessarily mutable. So, there's no benefit in terms of

Re: [rust-dev] let mut - var

2014-01-29 Thread Huon Wilson
Running the same commands just inside src/librustc (which is essentially client code) gives: let mut = 1051 let (no mut) = 5752 So the ratio is even more skewed toward immutable lets, and, librustc is written in old Rust, so I can only see the ratio moving away from let mut even more: e.g.

Re: [rust-dev] let mut - var

2014-01-29 Thread Clark Gaebel
'let mut' signals a let binding to a mutable variable...? On Wed, Jan 29, 2014 at 10:26 PM, Samuel Williams space.ship.travel...@gmail.com wrote: Interesting - so if there is no difference, what is the point of let mut ? On 30 January 2014 16:21, Patrick Walton pcwal...@mozilla.com wrote:

Re: [rust-dev] let mut - var

2014-01-29 Thread Jason Fager
You *should* get sick of writing 'let mut' all over the place, not just b/c of the syntax but b/c you're using mutable variables all over the place. Casual mutability kills maintainability. Affordances matter. I'm convinced that the reason Option.unwrap() is used so frequently is b/c it's the

Re: [rust-dev] let mut - var

2014-01-29 Thread Samuel Williams
Jason, I haven't actually written any rust code (yet). I'm just commenting based on reading other people's code - it was something I noticed in a few examples - it might have been bad form (assuming that mutable data are the Wrong Thing?). I brought it up because I wasn't sure if it was something

Re: [rust-dev] let mut - var

2014-01-29 Thread Haoyi Li
Sorry to parachute in to the conversation (long time lurker) but just to add to the statistics, the Scala standard library and compiler has 11875:54575 ratio of mutable (var) vs immutable (val) declarations, so it seems to match pretty well with the numbers you guys are seeing in the rust

Re: [rust-dev] let mut - var

2014-01-29 Thread Gaetan
I like the fact that is more expensive to write let mut than let. So you initialize mutable variable on purpose Le 30 janv. 2014 05:31, Haoyi Li haoyi...@gmail.com a écrit : Sorry to parachute in to the conversation (long time lurker) but just to add to the statistics, the Scala standard

Re: [rust-dev] let mut - var

2014-01-29 Thread Olivier Lemaire
Hi list, I’d like the fact “a = 10” or “mut a = 10” are shorter to write than “let a = 10” or “let mut a = 10”. On the other hand, I *really* appreciate the fact `grep -ri let src/ | grep (or -v) mut` will return me quickly where the variable declaration are. So in the end, I feel I can