3 ms·
> Rust as a language is now realizing the benefits of borrow checking. As the article points out, the syntax doesn't have to distinguish between move and assig
by dbaupp 10y ago
> Rust as a language is now realizing the benefits of borrow checking. As the article points out, the syntax doesn't have to distinguish between move and assign. The borrow checker will catch a reuse of something already moved away. This turns out to be effective enough in practice that the syntax distinction isn't necessary. That wasn't obvious up front.
Could you say a bit more about what you mean by "now"? You write like it's a recent realisation but (as linked in the parent article) it was "discovered"/described/promoted more than 4 years ago: http://smallcultfollowing.com/babysteps/blog/2012/10/01/moves-based-on-type/ http://smallcultfollowing.com/babysteps/blog/2012/10/01/move... .
---
Are your other two paragraphs related to the article, or are they just your general observations about Rust?
- deleted 10y ago[deleted]
- Animats 10y agoNever read "smallcultfollowing" before. The "implicitly copyable" problem is amusing. That was dealt with by Wirth in Modula 1 with the rule "if the programmer can't tell, it's up to the compiler". Thus, non-writable objects could be passed either by reference or by copy, depending on object size. This was up to the compiler. The usual rule was that anything up to 2 words in size was copied. Since the called function couldn't change the value, it didn't matter. This avoids philosophical gyrations. You want a rule that says you can copy ints and floats, for performance reasons. Trying to reach that via type theory makes it harder. It's an optimization.
- pcwalton 10y agoWe tried making copy/move an optimization. The number of useless copies that ended up in the resulting code was absurd. You think compile times are bad now…
- Animats 10y agoYou mean there were lots of copies that made it to the back end, only to be converted to non-mutable references late in the compilation process?
- pcwalton 10y agoHow do you convert copies to non-mutable references? That involves proving things about aliasing. Even in Rust that is not that easy…
- Animats 10y agoThe other way round. Sometimes you want to convert non-mutable references to non-mutable copies. This is almost always a win for int, float, etc., and usually a win for anything up to 8 bits on a modern processor.
- uabstraction 10y agoI'm going to nitpick and suggest that you almost certainly meant 8 _bytes_.
- dbaupp 10y agoFortunately there's no need to have read all of the (very interesting) archives of Niko's blog in this case, as the parent article linked to that post in the relevant section too.