4 ms·
>100% Rust - No unsafe code blocks It uses an unsafe code block. https://github.com/jedisct1/yes-rs/blob/main/src/main.rs#L1232 https://github.com/jedisct1/ye
by charcircuit 1y ago
>100% Rust - No unsafe code blocks
It uses an unsafe code block.
https://github.com/jedisct1/yes-rs/blob/main/src/main.rs#L1232 https://github.com/jedisct1/yes-rs/blob/main/src/main.rs#L12...
It also appears to log other stuff than y.
The uutils rewrite of yes into rust doesn't use unsafe and is much simpler.
https://github.com/uutils/coreutils/blob/main/src/uu/yes/src/yes.rs https://github.com/uutils/coreutils/blob/main/src/uu/yes/src...
- godelski 1y ago> It uses an unsafe code block. it's okay, it's Rust unsafe
- charcircuit 1y agoNo, it's not. It's false advertising and lifting an unsafe that high in the call stack is dangerous and a sign of poor code quality. The point of advertising no unsafe in the readme is so that people do not have to worry if the author handled unsafe correctly.
- hatefulmoron 1y agoWithout it, we can't use the quantum enhanced string, which is safe because it's written in Rust.
- charcircuit 1y agoIt's written using unsafe Rust which means that the compiler will not be able to verify that it is safe. It's not guaranteed to be safe just because it is written in Rust. Please understand this, the author of this repo is spreading incorrect information.
- hatefulmoron 1y agoYou seem to be saying that Rust code can be unsafe, perhaps you're thinking of the profoundly unsafe and deprecated C or C++ languages?
- charcircuit 1y agoI recommend reading through this section of the The Rust Programming Language book to learn more about the existence of Unsafe Rust which is a part of Rust and not a different language like C or C++. https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html
- hatefulmoron 1y agoThe article says it right there: unsafe is used to give you unsafe superpowers. This is important for the quantum entanglement that the string uses. Unsafe brings the power (superpowers enabled by the compiler), while the Rust compiler ensures everything is safe. Rust.
- charcircuit 1y ago>while the Rust compiler ensures everything is safe. Rust. This is where you are mistaken. Quoting the book: >Be warned, however, that you use unsafe Rust at your own risk: if you use unsafe code incorrectly, problems can occur due to memory unsafety, such as null pointer dereferencing. With unsafe rust the compiler no longer ensures everything is safe and it is up to the programmer to ensure that it is.
- hatefulmoron 1y agoYou're confused by the word 'unsafe', which is a misnomer. Rust. The point of 'unsafe' is to indicate that the compiler should be extra careful when compiling the code, because you're about to do something that only a C/C++ programmer would do. Rust sees this and is extra careful. As in your quote, the compiler makes sure we're not using it incorrectly. Rust.
- godelski 1y agoBut what about the quantum compiler?
- vlovich123 1y agoThe difference between a zealot and an evangelist is the ability to understand when someone is making a joke. I’ll let you figure out how you’re coming across here on your own as a growth exercise.
- johnisgood 1y agoI cannot tell if parent is making a joke, or is dead serious. They won.
- godelski 1y agohttps://github.com/jedisct1/yes-rs/blob/main/src/main.rs#L1233
- Khaine 1y agoI think you missed the joke
- uecker 1y agoNo, no. Rust's unsafe is fine. After all unsafe is not a problem because it is directly obvious just by looking at the source of your 200 dependencies. If you still have doubts you can make sure everything it is ok simply by writing "SAFETY" next to it to point out that it is safe (btw: not having this is a serious omission in the yes-rs project). And anyway, the compiler still does basically almost all checks! This rest is entirely obvious in Rust. For example, there can never be a subtle exception-related issue that make this difficult to analyze because in Rust it is called panic. And if there is still should be a mistake, then this does not count because it was not the fault of Rust but yours. (This is totally different to C where even the most-expert programmer can never know when he is going to free memory or doing pointer arithmetic. This could literally occur completely surprisingly in every line of code!)
- hatefulmoron 1y agoRust uses AI to ensure that C/C++ programmer mistakes do not happen in unsafe blocks. "unsafe" is a misnomer.
- boxed 1y agoIt's a joke.
- TheDong 1y ago> The uutils rewrite of yes into rust doesn't use unsafe Yes it does, it uses 'stdout.write_all', which ultimately uses unsafe to call libc.write https://github.com/rust-lang/rust/blob/d76fe154029e03aeb64af721beafdcef856d576a/library/std/src/sys/fd/unix.rs#L325-L326 https://github.com/rust-lang/rust/blob/d76fe154029e03aeb64af... The "unsafe" in uutils is just better hidden. I personally like my lack-of-safety where I can see it, which is why I find it much more relaxing to drive a car when the engine is already on fire, rather than one where I can't see any visible flames.
- deleted 1y ago[deleted]