6 ms·
Some of the complaints are perfectly fair (compile time, powerful but unwieldy macros). Other complaints seem a bit odder to me: >While overall built-in testin
by simias 9y ago
Some of the complaints are perfectly fair (compile time, powerful but unwieldy macros). Other complaints seem a bit odder to me:
>While overall built-in testing capabilities in Rust are good (file it under good things too), the fact that benchmarking is available only for limbo nightly Rust is annoying;
Okay, but what are you comparing it against? Neither C or C++ have builtin benchmarking or even tests.
>If you care about systems programming and safety you’d have at least one or two functions to convert type into a smaller one (e.g. i16/u16 -> u8) and/or check whether the result fits.
I don't understand this one at all. What's wrong with "as"? And if you need a checked conversion just write a small wrapper function? Again, if you're comparing to C or C++ I'd argue that Rust's semantic are friendlier and a lot less error prone at the cost of increased verbosity. C will implicitly cast and promote integer types without asking any questions, Rust makes it explicit.
I understand C promotion rules and I've still managed to get it wrong on occasions, to the point where I now force myself to make all casts explicit in C like I would in Rust. At least this way the intent is obvious, as I think it should be.
>Also the tuple assignments. I’d like to be able to assign multiple variables from a tuple but it’s not possible now. And maybe it would be nice to be able to declare several variables with one let;
So unless I'm missing something something like:
let (a, _, b) = (1, 2, 3)
>Same for function calling—why does bitread.seek(bitread.tell() - 42); fail borrow check while let pos = bitread.tell() - 42; bitread.seek(pos);
Yeah, that's always been a minor annoyance of mine too. I intuitively think that
a(b());
should be treated like
let tmp = b();
a(tmp);
That is b() would terminate and release its borrows before a is even considered and "tmp" would live until the end of the block.
I'm guessing that there must be a good reason why it isn't so however.
Note that in C and C++ parameter evaluation order is unspecified so calling functions with potential side effects in parameter lists should be done very carefully. The compiler won't ever stop you though, don't worry. I'm sure the foot will grow back eventually.
>Borrow checker and arrays. [...]
Now this whole section feels a lot like "I'm trying to code in Rust like in C and it doesn't work and it frustrates me". Which is fair, messing around with arrays in C is a lot easier than Rust, there's no doubt about that. C also makes it massively easier to spectacularly shoot yourself in the foot if you mess up.
Yes, if you need uninitialized arrays and these sorts of things you need to use unsafe. But that's mostly optimization and you probably don't want to start implementing your codec with that type of code. After all maybe the compiler will be clever enough to see what you're doing with the buffer and not actually run the init code. And if it doesn't you're free to add the unsafe code later, once your codec works, you have good tests and it's time to optimize more aggressively.
>And that’s why C is still the best language for systems programming—it still lets you to do what you mean (the problem is that most programmers don’t really know what they mean)
Ah, so after the Sufficiently Smart Compiler we have the Sufficiently Smart Coder. That seems like quite a definitive claim for somebody who didn't know about "split_at_mut" in Rust a few lines earlier. Maybe the author should experiment a bit more with the language before making bold statements like these?
It's not rare to find security vulnerabilities in codecs and they tend to be extremely exposed. Maybe it's worth the hassle of making array manipulation slightly less convenient for the sake of security?
>type keyword. Since it’s a keyword it can’t be used as a variable name and many objects have type, you know.
All languages have reserved keywords, that's strictly in bikeshed territory. Of course when you get to a new language with a new set of reserved keyword you have to learn new habits. You never name anything "struct", "class", "switch" or "break" in C or C++ because you're used to have these keywords removed. Rust lets me name variables "class" but not "type". Oh well.
>Not being able to combine if let with some other condition (those nested conditions tend to accumulate rather fast)
I tend to agree with this one, although I guess it could become messy quickly if you mix refutable lets with regular boolean conditions.
- masklinn 9y ago> I don't understand this one at all. What's wrong with "as"? That it silently overflows. > And if you need a checked conversion just write a small wrapper function? A better suggestion would be to wait for TryFrom/TryInto which IIRC should be stabilised soon-ish. > So unless I'm missing something something like: Assignment (https://doc.rust-lang.org/reference/expressions.html#assignment-expressions https://doc.rust-lang.org/reference/expressions.html#assignm...) not declaration (https://doc.rust-lang.org/reference/statements.html#declaration-statements https://doc.rust-lang.org/reference/statements.html#declarat...). So (a, b) = (1, 2) given pre-existing non-redeclared a and b. Of course this is not very useful for such a trivial example but a common case is some sort of procedural loop e.g. let (mut a, mut b) = (0, 0); for it in thing { (a, b) = <something> } // use a and b here currently you have to assign to (1+) temporary variables before porting that to the actual bindings you care about.
- simias 9y agoIt's true that a "checked_as" would come handy from time to time and seems to be in line with the "Rust spirit". But again, since the author seems to be arguing in favor of C it seems like an odd complaint. C even makes it tricky to check for integer overflow while Rust has the checked_ family of functions. In C if you get it wrong it's undefined behavior territory baby. Ditto with the tuple thing, C doesn't have tuples and won't let you destructure anything. I guess my overall point is that these complaints seems to pit Rust against some other high level languages like Common Lisp or Haskell but his conclusion is basically "C rulez, Rust droolz".
- dgfgfdagasdfgfa 9y agoAlso, detecting overflow while casting seems pretty trivial to implement as a macro itself if you aren't willing to wait for the language to pick up the need.
- andolanra 9y agoThere is an open issue (an old one!) about assignment to tuples, but it's not entirely a no-brainer as to how to implement it while keeping Rust's grammar LL(k): https://github.com/rust-lang/rfcs/issues/372 https://github.com/rust-lang/rfcs/issues/372