5 ms·
Isn't the problem with Rust that it uses crappy pessimistic heuristics (borrow checker) for essentially NP-C problem, causing complaints where code is perfectly
by bitL 9y ago
Isn't the problem with Rust that it uses crappy pessimistic heuristics (borrow checker) for essentially NP-C problem, causing complaints where code is perfectly OK? IMO interesting design decision but I am staying away precisely because of this.
- tatterdemalion 9y agoDo you stay away from all type systems? This would be an accurate negative framing for any type system, which all necessarily reject some correct programs.
- bitL 9y agoNot really. Just it's super difficult to understand how exactly borrow checker operates and when would it allow program to compile or not, causing all kinds of unpredictable situations and unless you are "black belt"-level, difficulty providing any estimates. Not mentioning loss of morale when you have to fight it every single day.
- tatterdemalion 9y agoThis is not my experience using Rust. I had six months of programming experience when I first tried Rust. I definitely got confusing errors at first, but I grasped the system within a month or two. And that was in 2014 - the borrowchecker and especially its errors have way improved since then! But this is also a very different objection from your initial objection, which was just a statement of fact about type systems for turing complete languages.
- pjmlp 9y agoHave you tried to write GUI code in Rust?
- bitL 9y agoI'll take a look once I am done learning another hot language ;-) Thanks!
- hateduser2 9y agoSo your issue isnt about rust, its about changing popularity and language trendiness?
- bitL 9y agoNot at all; currently I am able to write non-trivial programs in >60 languages and ranging from low-level distributed transactions (did own Paxos already) through 3D visualizations, business software, mobile apps, Deep Learning models and AI, system software all the way to advanced ETL pipelines using imperative, functional, logical, co-routine-based, generics, reactive, declarative etc. concepts and am always on the lookout for a better language as I can't find the perfect one ;-) So I want to understand where Rust stands and if it is meaningful investment to learn it, both programming "pleasure"-wise and business sense-wise.
- SamReidHughes 9y agoIs it? Could you give an example? I've found a borrow checker bug in the current release but the rest of the time its behavior is perfectly predictable. Granted, I wouldn't be surprised if the documentation was horrible, my understanding of the checker is based on one way I would do it.
- bitL 9y agoIt's simply one more thing you need to keep in your internal "context" while writing a program, taking mental resources you could spend elsewhere. Perhaps an IDE guiding you and outright rejecting the code or offering code completion that is compatible with borrow checker might be a solution, though we aren't there yet I believe.
- SamReidHughes 9y agoYou have the same thing in C++, right?
- bitL 9y agoYes, and sometimes I wish C++ stayed somewhere in pre C99 levels where a single person could master it. As much as new features are useful, they make codebases unreadable to anyone that doesn't grasp all concepts. Even Google internally "javaizes" C++ and uses a strict subset to keep some sanity. Scala is another language that can go insane in the same fashion if teams don't enforce strict rules.
- SamReidHughes 9y agoRust is a "Javaization" of C++ checked by the compiler.
- adrianN 9y agoYou have to keep the kind of problems the borrow checker nags you about in your mind anyway. Memory errors and concurrency problems don't go away because the compiler doesn't complain about them. Personally, I find it easier to use Rust than C++, because I don't have to worry so much about iterator invalidation and stuff like that.
- cortesoft 9y agoI think this comes down to philosophy; do you want the compiler to just check that the program works for all the current parts, or to have the compiler make sure that the program will work for all the possible ways the interfaces can be used as described? Basically, Rust makes you ensure that your code can actually do all the things it says it can do, not just the things it is currently doing. Personally, I find that very helpful; I would rather do the work up front than have to go back and fix a lot of things later as my code grows. This might be based on my experience designing and maintaining very long lived systems, where I wish I had been forced to do things correctly from the beginning.
- bitL 9y agoI'd love if it were able to predict correctness of the program, but it can't (halting problem something). It can only approximate it and to be meaningful, it has to be pessimistic. Which is one more headache to casual developers.
- bronson 9y agoAre you saying that Rust is trying to predict the correctness of the program? Sure, parts like deadlocks and memory use, but the whole thing? This seems to be a common misconception, maybe from interacting with overzealous Rust fan clubbers.
- ohazi 9y ago"Crappy pessimistic heuristics" Are you talking about the borrow checker from half a decade ago? [0] Have you used the language since then? This is FUD -- it's really not hard to get code past the borrow checker anymore. Maybe every thousand lines or so you'll need to add a block or pull a temporary variable out of a one-liner, but the compiler basically tells you exactly what to do when something like that is relevant. [0] https://pcwalton.github.io/blog/2013/01/21/the-new-borrow-check-in-a-nutshell/ https://pcwalton.github.io/blog/2013/01/21/the-new-borrow-ch...
- pjmlp 9y agoTry to use the borrow checker of this decade to write callbacks in GUI frameworks, without polluting the code with Rc and RefCell, even though it is obvious there is only one path to the data being used.
- Rusky 9y agoCallbacks by definition create multiple paths to the data. (You can also often get away with Cell rather than RefCell.)
- pjmlp 9y ago> Callbacks by definition create multiple paths to the data. How come, when you have a struct method, accessing field members only visible to that specific method. Something that is very easy to do with moving in lambda contexts in C++.
- pmarcelll 9y agoThe quoted sentence is not true, but most practical callbacks will create multiple paths to objects via borrows. Or you can move your structs into closures (like in C++). But I think what you originally wrote (using callbacks without Rc/RefCell) is fundamentally hard. You have to guarantee somehow that the struct is still alive when you access it though the borrow in the callback, otherwise you have a memory safety problem.