News for hackers. Stuff that matters.
Re:Making C++ Safe Without Borrow Checking, Reference Counti... by adamnemecek on Friday June 23, 2023 @09:13PM (#36454419)
> If the choice is a Rust library with 95% of the code in unsafe blocks, ... Rust is not providing any real safety benefits in that situation, is it?

If the choice is a C library with 95% of the code in inline assembly, ... C is not providing any benefits in that situation, is it?

Re:Making C++ Safe Without Borrow Checking, Reference Counti... by kbenson on Friday June 23, 2023 @09:59PM (#36454704)
Exactly. Presumably there are some opt-in tools that are very strict about the inline assembly uses you have in C. I don't have any experience with them, but I'm sure they exist.

That's the whole point, it's less about the language, and more about the specifics of the code itself in a testable way. Saying something is written in C without accounting for a bunch of inline assembly is analogous to saying something is written in Rust and not accounting for a bunch of unsafe blocks. Not in that they are equivalently safe or unsafe, but that that high level assumptions because of the language fail because of the practices done within.

If I had to choose between two libraries written in C and one was pure C and one was 50% inlined assembly, and I viewed security and safety as more important for my use case, I know which one I would choose if that information was surfaced to me easily.

Re:Making C++ Safe Without Borrow Checking, Reference Counti... by adamnemecek on Friday June 23, 2023 @10:05PM (#36454750)
There are no Rust crates with 95% unsafe code.
Re:Making C++ Safe Without Borrow Checking, Reference Counti... by barsonme on Saturday June 24, 2023 @03:34AM (#36456450)
Crates that only make FFI calls exist. I have written some. :)
Re:Making C++ Safe Without Borrow Checking, Reference Counti... by kbenson on Saturday June 24, 2023 @03:13PM (#36461784)
If you think I'm talking about rust vs C and not just using them as stand ins for any language pair, you're not understanding my point because you're too focused on one language in particular, while I'm not focusing on any language in particular.
Re:Making C++ Safe Without Borrow Checking, Reference Counti... by spoiler on Saturday June 24, 2023 @04:13AM (#36456640)
People have this misconception that unsafe Rust is some other language. It's not. All it does is allow the use of raw pointers. So, all other Rust feature (ie type system) still work as they always did. So, you can really minimia the surface are of unsafe code. Not to mention seeing unsafe just means that something really low level is happening, and signals caution to the reader (or anyone editing the code), as opose to C++ where it's easy to forget you need to be alert, since you should be alert all the time really.