4 ms·
Yes and no. It provides some kinds of (important!) static analysis out of the box, but at the cost of complexity, which directly adversely affects some other ki
by pron 7y ago
Yes and no. It provides some kinds of (important!) static analysis out of the box, but at the cost of complexity, which directly adversely affects some other kinds of (also important) static analysis. For example, there are sound static analysis tools that guarantee no undefined behavior of C code, but AFAIK, such tools can at best only work on a subset of C++, because of its complexity.
Rust goes all out on eliminating undefined behavior, and may well be the best way of doing that in low-level programming, but eliminating UB is just a means to an end, UB is not the only source of dangerous bugs, and if the cost of eliminating it is high it may not be the best way overall of reducing bugs in low-level languages.
- amelius 7y agoAlso, ownership checking only seems to work well for tree-like datastructures, but implementing something with cycles (back-pointers) immediately leads to nasty problems.
- zozbot234 7y agoThat's not a problem with Rust, it's a problem with back-pointers. You basically just need to fall back on raw pointers and do all the correctness checking yourself, precisely because the ownership model is not that helpful here. (Although if there is a pattern of "owning" references which involves no cycles plus back-pointers that are actually identifiable as such, that is directly supported via Rc<> and Weak<>.)
- deleted 7y ago[deleted]
- mcqueenjordan 7y agoWhat is the complexity, and what are its costs? As an active user of Rust, I haven't seen the (adverse) complexity or its costs yet. It's worth pointing out that Rust combats more than undefined behavior. Undefined behavior is a category of bad things that Rust works to eliminate, but Ownership goes beyond eliminating UB, and eliminates a large swath of potential logic bugs.
- Thaxll 7y agoProgramming in Rust is complex, I'm not sure how can argue against that, it is not straight forward to do simple tasks because of how you need to organise your architecture with the borrow checker. Most people that starts using Rust get stuck on issues that you woudn't have with other languages.
- steveklabnik 7y agoIt’s not that simple. Rust’s rules also make more complex tasks specifically easier, at least for me. YMMV.
- adamnemecek 7y ago> Programming in Rust is complex Make a distinction between programming and the overall programmer experience. C++ is not a simple language and it feels like some of the the rules are arbitrary, vendor dependent, or for the same of backwards compatibility. When programming C++ at scale you start dealing with manifest files. Different understanding of C++ (templates/precompiler? exceptions? std? the list goes on). Rust on the other hand is mostly pleasant. Sometimes I have problems with cargo. However like C++ build systems made life legitimately miserable sometimes. I'm really excited for Rust. I think that at some point it might replace large parts of the OS. I can imagine important parts of the internet (DNS servers, caching servers etc) running on raw hardware. Your OS eats too much of your perf. You are right, some parts of Rust are tricky (still working out proc_macros) however you get a lot of power from these. It also feels like the Rust team really thinks ahead. Like C++ is still working on the Range type. Originally, it was supposed to be in C++03 but that didn't happen and here we are 17 years later still waiting. You can say things like that the type system doesn't support higher kinded types and such. You are right and I think that at some point, Rust will get them, right now there are more important battles. Whoever manages to implement them will be crowned the king of Rust I'm sure.
- estebank 7y agoIn my experience the difficulty of picking up Rust is most pronounced for people experienced in other languages that have common design patterns that are discouraged or made impossible by Rust. It's harder to unlearn something that from your point of view works (even if it had hidden or clear drawbacks) when you're also having to learn other things simultaneously. Also, I feel the biggest hurdle Rust has for experienced developers from other languages is that Rust makes some ineficient code visible, but the way of optimizing it requires delving into more advanced parts of the language, frustrating people when they are most "vulnerable". This is where the common piece of advice for people starting with rust "just clone for now and don't think about it" comes from: get used to the language first and deal with borrowing on its own at a later time. But all of this frustrating learning curve comes to fruition later in when writing code because the experience is closer to pair programming with the compiler rather than trying things in a vacuum on your own.
- Ar-Curunir 7y ago> sound static analysis tools that guarantee no undefined behavior of C code, but AFAIK, such tools can at best only work on a subset of C++, because of its complexity. What tools are these, and why haven't they been deployed across every C codebase to prevent memory safety bugs?
- pron 7y agoE.g. Trust-in-Soft, and while they're cheaper than a rewrite in Rust, and so they're also used more than Rust, especially in safety-critical software, they do require some effort. I don't know how much "every C codebase" is willing to spend to become UB-free.
- marcosdumay 7y agoHum... UB is a huge source of analysis complexity. If are not comparing it with an insanely restrictive dialect of C (that will bring a lot of code complexity by itself), or I will love to see those static analysis tools that are better than Rust's.
- pron 7y agoThey're not "better" than Rust (I'm not even sure what that means), but they're cheaper, and that's why they're more popular. I'm referring to Trust-in-Soft (the people behind Frama-C) and some other similar tools, although I now see that TiS say they support all of C++11.