13 ms·
How Rust can facilitate new contributors while decreasing vulnerabilities [pdf]
- anuraaga 3y agoI guess because only the 1/70x configure their c++ toolchain with sanitizers. Assuming the paper is actually relevant given anyone can post any PDF to hacker news and make it semitruth.
- jjgreen 3y agoBecause they're 70x less likely to create an executable? [ducks for cover]
- bheadmaster 3y agoBecause they're 70x less likely to get to the point where their program compiles successfully. (only half-joking...)
- qsort 3y agoI mean, yes, literally. As much as the "rust for everything" folks are annoying, wrong programs not compiling is the entire point of having a powerful type system correctly leveraged. This is the kind of task where rust truly shines. ease of programming != ease of making undetected mistakes
- littlestymaar 3y ago“The safest program is the one that doesn't compile”
- smaudet 3y agoI think it is a separate study whether developers find it easier to actually use, things like environments being equal. I remember another study which showed that actually, most computer programmjng languages today are objectively terrible in terms of legibility and usability, the alternative was some idealized language that allowed effective communication to occur. A safe program is not necessarily one that won't compile, if the lack of functionality incurs some danger on its own. I suspect that a majority of the peanut gallery is rather lazy, or unwilling, or economically unmotivated to put forth the proper effort (and it is the last category that deserves the harshest punishment, where a wasteful and harmful situation is actively encouraged).
- usrbinbash 3y ago> ease of programming != ease of making undetected mistakes Disagree. GCed languages prevent the majority of errors the higher complexity of Rust unloads on the programmer to solve by wrestling with its syntax. So this is only a plus for Rust, if the small performance advantage over, say, Go, actually matters in an application, which is rarely ever the case in most software written.
- cyber_kinetist 3y agoYup, and if you actually meet a use-case where Rust has a major performance advantage above Go, typically you’re already too deep into the low-level details of optimization that you’ll constantly fight with the borrow checker or just scatter unsafe all over your code.
- baq 3y agoThis is just not true. The experience is typical if you know how to solve your problem in a GCed language and the solution is to solve problems the Rust way, primarily by using handles (and/or arenas) instead of references.
- swsieber 3y agoI'm actually a really big fan of affine types and adts with great pattern matching. The performance is nice too, but I stayed for all the other nice bits that are put together really well (except async, but eventually...). Rust has been my favorite language by far to refactor in.
- qsort 3y agoWe aren't really disagreeing. Forcing Rust into a domain where a GC'd language is more than enough offers absolutely zero advantages (yes, you'll have no memory safety issues, but neither you would have had you used Python or Java or Go or whatever), and it's the kind of obnoxious overzealousness that I'm denouncing. If you're using Rust to write web services you're just wasting your time, I agree with that. But if the alternative would be C or C++, Rust is at least worth consideration. Ironically, those are domains where you'll have to use a lot of unsafe and/or limit yourself to a subset of Rust, but it's still a nice incremental improvement.
- throwuwu 3y agoIt’s rather self defeating though isn’t it?
- anon23432343 3y agoBecause they are still compiling? [ducks for cover]
- CoastalCoder 3y agoNah, it's because they're 70x more likely to get their vulnerabilities via crate supply chain attacks! [pulled off stage with a cain]
- keepamovin 3y agoCan anyone suggest a good rust tutorial? I think I finally should learn this.
- EspressoGPT 3y agoThe official Rust book is the way to go. That being said, you "should" only learn it if this is actually your domain – for example because you're a C++ developer currently or so. You really don't need it in other software engineering domains.
- timeon 3y agoIt is useful in other domains as well.
- MSFT_Edging 3y agoI agree with the official Rust book, but I disagree that one shouldn't learn it. Rust, even as a learning exercise, makes you think about a lot of concepts you'd normally not notice. It is a fun language, fun to experiment with, and due to its learning curve, it'd be far less stressful to learn the basics ahead of time if you ever needed it. I used Rust-python bindings on a small project where we didn't want to use big python math libraries for portability, but a few of our calculations ran really slow on python primitives. Re-wrote a couple functions in Rust for a 40x speedup and its fully switchable to return to the original python implementations.
- EspressoGPT 3y agoYes, it's worth looking into the language and its concepts. But I think many people feel bad for not knowing or not having tried Rust because the Rust community tends to be very vocal and not quite reserved, and I believe that's a mistake. Not knowing Rust doesn't make you a bad software engineer, as opposed to what some Rustaceans want to make you believe.
- MSFT_Edging 3y ago
- EspressoGPT 3y agoRust newcomers are 70x more likely to mention what language they use than C++ newcomers.
- littlestymaar 3y agoYou haven't been much around C++ people, have you?
- KingEllis 3y agoWell, either no, or I would not know, as the point is C++ programmers are not nearly as self-congratulatory.
- littlestymaar 3y agoNot self-congratulatory, but bragging about being a real programmer ™ and not part of the ”webdev pleb”.
- jhoechtl 3y agoThere are many funny comments in here but I think they are all valid in a tragic-comic way. Rust is actually that hard that only a small share of developers will ever master it and those who master will be certainly the more intelligent one.
- EspressoGPT 3y agoMore persistent, not more intelligent.
- deleted 3y ago[deleted]
- robertlagrant 3y agoI don't know if this is true compared to C++. It's not as though it's easy to pick up a C++ codebase. Some languages, yes, but I wouldn't say C++ is one of them.
- agluszak 3y agoRust isn't hard. Programming in general is hard. Rust makes this difficulty explicit.
- jvanderbot 3y agoThis is a very good way of looking at it, actually.
- anonzzzies 3y agoAgreed, however, Rust is now treated like the hammer that also plagues js/ts. A GCd language is still just easier to use.
- cyber_kinetist 3y agoOr I would say, programming in general is already hard. Rust makes it even more difficult… The reason is that actual common memory safety mitigation strategies in real life involve using some kind of smart pointers (same with Rust and C++), or using indices with bound checking (same with Rust and C++, it’s just that C++ STL has this off in Release mode by default…). For both languages, trying to avoid these runtime mitigation strategies (which affects performance) will require doing some level of unsafe stuff which the compiler doesn’t help with you (the unsafe semantics of the two languages are actually similar since Rust relies on LLVM which relies on C semantics). So ultimately, the borrow checker doesn’t seem worth it if you actually think about the cognitive overhead and headaches it brings. The only reason Rust has an edge over C++ is that it has sane defaults and a better standard library (ah only if C++ had a sane way of initializing values…)
- boxed 3y agoSeems low to me...
- bluetomcat 3y agoAren’t C++ newcomers embracing “modern C++”? Touching new and delete is a feature for advanced users. Most newcomers can exist happily solely with STL containers, RAII and smart pointers.
- harrid 3y agoFor some reason, the comparison is always current rust Vs 20 year old c++. Mentioning that "modern" (12 year old) c++ does not have these problems gets downvoted. Completely unrelated: there are at least two dedicated anti c++ communities.
- littlestymaar 3y ago> Mentioning that "modern" (12 year old) c++ does not have these problems gets downvoted. Because it's false, that's why. Modern C++ still has many/most of C++ problems. It solves a bunch of them, but far from all. And telling the opposite to newcomers is a lie that's hurting them because they can end up making even more mistakes than the previous generation, since they were told they didn't have to pay attention thanks to “modern C++”.
- tubthumper8 3y ago> Mentioning that "modern" (12 year old) c++ does not have these problems gets downvoted. I'm not a C++ user but I thought that all of these things are still in "modern" C++, that the new editions only add things, not remove? Are there tools that can automatically rewrite existing code to use the "modern" features?
- harrid 3y agoAnd that's a criticism I can take to a degree on behalf of the language. These relics are still in because mistakes are happening in the governing body. However in practice, they don't matter much. Every CPP dev has a little helper running in the background which immediately flags these mistakes and can auto correct them. It's not an issue, just an annoyance.
- 3y ago
- zevv 3y agoI wanted to use Rust on embedded. I probably gave up way to early. But I really could not do it. This is how to set a GPIO bit, from the official "Embedded Rust" book: MY_GPIO.borrow(cs).borrow().as_ref().unwrap().odr.modify(|_, w| w.odr1().set_bit()); I tried. I really tried.
- dijit 3y agobecomes much more readable when you newline before each period. Though to be honest I am sure someone will pop up with a much easier and cleaner way to do this.
- ykonstant 3y agoI'll be keeping an eye on this then, because the above code is ridiculous; if it's the best (code-wise or performance-wise) way to do it in Rust, I can see the complaints.
- dralley 3y agoIt wouldn't be that much simpler if it wanted to do the equivalent thing in C. This is code for "set a pin in a completely thread safe way", whereas a lot of the comparisons are "set a pin". Which, as others have already pointed out, brings us to the very topic of this post. Rust prevents novices from messing up partly by forcing them to acknowledge ways in which the code might break, and it does that via the type system.
- taneq 3y agoThat’s gotta have improved by now… right? Right??
- xinayder 3y agoWait until the borrow checker complains that you are borrowing an immutable value
- 3y ago
- secondcoming 3y agoI'm surprised that some of the Rust ports still had security issues, especially in things seemingly trivial like audio and colour management.
- cyber_kinetist 3y agoCan’t be sure since you didn’t give specific examples… but I guess it’s because these domains (graphics, audio processing) requires the utmost performance and therefore needs to touch the unsafe parts of Rust frequently. Or they need to interface with operating system/driver APIs which are fundamentally unsafe. Writing inefficient safe code is easy(-ish). Writing efficient safe code is hard regardless of using Rust or not.
- esjeon 3y agoRust is just doing its job here, but it's PITA that Rust is extremely bad at letting people to write inefficiently secure code concisely (i.e. scripting languages like Python). It wants you to go all-in from the day 1.
- baq 3y agoIt's kinda the point, though. Runtime GC as in Python allows you to handle these problems during... runtime (which means you won't encounter some of them at all when learning - which is good!). Rust explicitly attempts to handle them at compile time, so the surface area of potential problems you might run into during runtime is much bigger. Rust with GC is somewhat like ocaml with ...; instead of let ... in.
- lindseyconcerns 3y ago[dead]
- pulse7 3y agoC/C++: You spend 45% of development time fixing memory bugs. Rust: You spend 45% of development time fighting with borrow checker/Rust syntax. GC-based languages: You spend those 45% for anything else you like...
- HKH2 3y agoBloated software is not a problem at all...
- timeon 3y agoGC-based languages: outsource 45% to the user.
- dale_glass 3y agoGenerally the later you detect the bug, the harder it is to fix. If it doesn't compile, you have to fix it, probably right after you finished typing it. You still have the overall idea of what you were doing fresh in your mind. If it compiles and then something weird happens a week later, you may spend days trying to reproduce it, then you'll have to pull out valgrind/ASAN, look at the dumps of that, figure what the hell does it mean that something goes wrong in the bowels of the STL/some other library, then backtrack from there to where that interacts with your code, figure if it's indeed a you problem or a library problem, remember again what this weird code is supposed to be doing, then finally fix, and do testing.
- rapsey 3y ago> Rust: You spend 45% of development time fighting with borrow checker/Rust syntax. Only a beginner. I spend practically no time fighting the borrow checker because I figured out how to structure my code to not have issues.
- sundarurfriend 3y ago> We also found that the rate of new contributors increased overall after switching to Rust, implying that this decrease in vulnerabilities from new contributors does not result from a smaller pool of more skilled developers That seems like a dubious line of reasoning. People learning the shiny new thing are going to be itching to use those skills in a (non-local, non-hobby) project, and that seems a much more likely explanation for why contributors increase during the stage where Rust is still shiny and new. An old codebase in an old language doesn't have nearly the same appeal, where contributions are going to come mainly because people want to scratch their own itches. It's a false comparison that doesn't contraindicate the self-selection effect at all.