6 ms·
I will probably get downvoted for this, but I feel writing any new libraries in C/C++ is a bit of a waste when Rust is now available. Especially for file format
by mrich 5y ago
I will probably get downvoted for this, but I feel writing any new libraries in C/C++ is a bit of a waste when Rust is now available. Especially for file format parsing which is prone to overflows and the like. Yes there are safe coding practices but why not just choose a better tool for the job.
- app4soft 5y ago> is a bit of a waste when Rust is now available. I will probably get upwoted for Libmobi and other C/C++, because Rust is a bit of a waste of time.
- bobthebuilders 5y agoRust is a language created by idiots who couldn't learn how to program C. I agree completely. Nobody uses Rust except for NFT and crypto shills, and that's because Rust is a rhetorical language created by a company that should be making free web browsers, not wasting time..m
- sirwhinesalot 5y agoJudging by the number of vulnerabilities that continue to be found every freaking year due to easily preventable problems, it seems nobody has learned how to program in C to this day. Yourself included. Having said that, Rust is a C++ replacement not a C replacement. The biggest selling point of C is being the thing every other language talks and running everywhere including embedded devices with crappy custom compilers. With both Rust and C++ you still need to write extern "C" wrappers which are suboptimal, even when partially automated, and neither runs everywhere.
- cultofmetatron 5y agoI'd say zig is more of the "safe" c replacement. Rust is more of a competitor to c++. I'm happy to switch to rust and be able to focus on making sure my logic is secure while letting rust take care of catching memory safety bugs for me.
- mrweasel 5y agoSome of us have no desire to learn Rust… well I did, but found the syntax to be awful. If you already know C, C++ or something else, you really need a good reason to learn a new language, especially one with a syntax as messy as the of Rust. That being said, you do have a valid point that file format parsing really could benefit from a language with the safety features of Rust.
- bitwize 5y agoI'd say making buffer overflow and UAF CVEs Just Go Away -- forever -- is a DAMN good reason to switch to Rust. I've found that prior exposure to C is somewhat negatively correlated with willingness to grok Rust. Something in their mind rebels against it, which is why I say that if you're an "old hand" C programmer who feels that the syntax of Rust is too hard, or the borrow checker is obscure, maybe you shouldn't worry about learining Rust because Rust isn't for you -- it's for your replacement. You're John Henry, the borrow checker is the mechanical spike driver, and no matter how hard you work at it all your programming discipline is just no match.
- fivea 5y ago> I'd say making buffer overflow and UAF CVEs Just Go Away -- forever -- is a DAMN good reason to switch to Rust. rocket Crate up to 0.4.6 on Rust uri::Formatter use after free https://vuldb.com/?id.172079 https://vuldb.com/?id.172079 If only people stopped with the cargo cult nonsense that leads to this absurd belief that adopting a tool is a silver bullet to fix their sloppy practices.
- futharkshill 5y agoC and C++ are completely different languages. The arbitrary parsing of data into structs in C is what makes it incredibly suitable for file parsing. Among other things.
- mrich 5y agoC is a subset of C++. The key point is that both languages suffer from the same problems, e.g. memory safety issues, undefined behavior, data races. The software industry has been dealing with the fallout of these issues for the past three decades. It's about time we moved the bar higher. By the way, the main data structure of my first large Rust program was simply a vector of a custom struct, optimized for memory footprint. Just like in C, with the same low overhead serialization. With C, you always have to be careful to not overrun a buffer. The recent NSS vulnerability is a great example of this: https://googleprojectzero.blogspot.com/2021/12/this-shouldnt-have-happened.html https://googleprojectzero.blogspot.com/2021/12/this-shouldnt... Even though this code was heavily fuzzed and tested, the problem slipped through. Not possible in Rust. Also, with Rust you can throw away all your sanitizer infrastructure and save all the associated costs.
- isitdopamine 5y ago> C is a subset of C++ It is not, they diverged since decades now. Still, even if this was the case, the programming styles are so different that there’s nothing to gain considering them as any more similar as any two other languages.
- ReleaseCandidat 5y ago> It is not, they diverged since decades now. AFAIK you always had to cast `void *` in C++ (like the return value of `malloc`).
- yaris 5y agoWhy on Earth would one use malloc in C++? Instead of using ’new’ if explicit allocation is desired.
- zppln 5y agoThis sentiment is getting so fucking tiresome. Just don't use it if you don't like it.
- ReleaseCandidat 5y agoAs of now (and for the following years), C (_not_ C++) is still the _only_ language which's libraries can be _easily_ called from (almost) any other language.
- mrich 5y agoIt's not hard to build a library in Rust that can be consumed the same way a C library can. Orders of magnitudes easier than getting your C/C++ program safe. https://docs.rust-embedded.org/book/interoperability/rust-with-c.html https://docs.rust-embedded.org/book/interoperability/rust-wi...
- zaptheimpaler 5y agoBecause the reason C/C++ codebases are getting hacked is not primarily because they're written in C/C++, its because they were written a LONG time ago when security didn't matter so much, the entire industry was much less mature and it was probably way harder to code, and management at companies would probably never allocate any time to a non-issue like that. Its just so completely uninformed and noob-ish to equate _tools_ to what people build with them. The language is not nearly as important as the programmer and the context in which the code was written. Its a very typical new-programmer thing to think language is all that matters, but most programmers with a few years experience understand how little it matters compared to everything else. You guys are basically like those old Christian missionaries who show up somewhere in Africa knowing nothing and insist the locals convert. Totally clueless..
- mrich 5y agoIf we are starting to get snarky: There are two kinds of people who choose Rust over C++. Beginners who think C++ is too hard, and seasoned developers with years of experience working in large teams who _know_ C++ is too hard to get right.
- zaptheimpaler 5y agoive been learning Rust and it doesn’t seem like the clear win fans say it is. i recently ran into a variant of this problem: https://doc.rust-lang.org/nomicon/lifetime-mismatch.html https://doc.rust-lang.org/nomicon/lifetime-mismatch.html i know the lifetimes are fine, but Rust doesn’t. in a memory unsafe language i would have to model the mutability in my head to ensure the code is fine. i now need to model the lifetime checker and its limitations/false positives _in addition to_ the underlying mutability to understand whether a compiler error is actually a bug in my code or not. and this is in an extremely short & simple program. a compiler that can truly enforce safety without too many false positives is definitely a win. but for now it seems like a leaky abstraction so it adds complexity instead of reducing it.