4 ms·
Rust isn’t as safe as GCed language and you don’t need systems level speed on a backend API. Rust’s safety is better than C/C++, but memory vulnerabilities are
by mr_00ff00 4y ago
Rust isn’t as safe as GCed language and you don’t need systems level speed on a backend API.
Rust’s safety is better than C/C++, but memory vulnerabilities are found in cargo packages because of unsafe code.
- satvikpendem 4y ago> you don’t need systems level speed on a backend API. I do, actually. > but memory vulnerabilities are found in cargo packages because of unsafe code. Forbid unsafe in your config and you're good.
- mr_00ff00 4y agoCorrect me if I am around, but Forbid unsafe does not include dependencies, which can and do have unsafe rust.
- satvikpendem 4y agoYou can use cargo-geiger to check whether dependencies have unsafe code too, along with your own code.
- Dylan16807 4y ago> Rust isn’t as safe as GCed language Safe rust should be. And C# is a notable example of a GCed language that also has 'unsafe'. Along with most of the GCed languages with FFIs.
- mr_00ff00 4y agoSafe rust can still use crates with unsafe rust, so no. Unless it’s safe rust and uses no outside code or none of its dependency tree has unsafe rust. It’s pretty crazy how many people will argue this point and downvote comments about it. It’s like a C++ dev claiming they never write memory bugs. I love rust, but the community pretending like memory safety bugs are impossible is as annoying as people claiming memory safety isn’t important. EDIT: And GC languages “can” call unsafe is not the same as a language that has unsafe in it. It’s laughable if you are claiming there are the same memory bugs in say Elixir as there are in Rust.
- Dylan16807 4y ago> Unless it’s safe rust and uses no outside code or none of its dependency tree has unsafe rust. If you already know what you want, why pretend there is no solution? But you skipped the other half of the post, where I explained that the average GCed language either has unsafe code or can easily call unsafe code or both, just like Rust.
- mr_00ff00 4y agoIf you are doing web backends, you are using crates with unsafe code. Again, I could write C code without memory violations hypothetically the same way I could use no crates, so I guess all rust rewrites are no longer necessary? As I said in the edit, GC languages are safer than an unsafe language like rust, even if you could find and call unsafe code. Again, I don’t know why to someone that uses rust I need to make that point. If a C++ dev argued using C++ is fine cause all GC languages can call unsafe code, would you agree? Cause if you do then we might as well end rust now, it’s not adding any safety. All language are unsafe!
- dgb23 4y agoThat's trivially true. But a web backend will preferably use: - A std library that provides much of the stuff you need to write web servers. - A few select well established, stable libraries to fill the gaps - A battle hardened database like SQLite, MySQL or Postgres - Maybe additional libraries and generators to program against specific, open protocols, standards and over the wire schemas, like json-schema/OpenAPI/GraphQL/Protobuf etc. Which are typically tested against a common test-suite. - Maybe additional components like message queues and key value stores and object storage in order to scale. You get the drift. It's not like these things are some random libs and tools that are maybe "unsafe" (whatever that means). A good thing about Rust is that unsafe is always explicit. And if you're not using the keyword, then satisfying the type checker gives a "if it compiles, it runs" feel, because runtime assertions can be avoided. But saying "anything is unsafe anyways" is missing the point. The language itself can nudge you towards a certain outcome, but I trust some of the mentioned technologies above, not because of the languages they use, but because they are well designed, stable and full of old battle scars.