News for hackers. Stuff that matters.
Re:Zlib-rs is faster than C by umanwizard on Monday March 17, 2025 @06:27AM (#43386891)
No you don’t. You can use the standard linked list that is already included in the standard library.

Coming up with these niche examples of things you need unsafe for in order to discredit rust’s safety guarantees is just not interesting. What fraction of programmer time is spent writing custom linked lists? Surely way less than 1%. In most of the other 99%, Rust is very helpful.

Re:Zlib-rs is faster than C by vikramkr on Monday March 17, 2025 @09:25AM (#43388348)
I think the point is that it's funny that the standard library has to use unsafe to implement a data structure that's like the second data structure you learn in an intro to CS class
Re:Zlib-rs is faster than C by tux3 on Monday March 17, 2025 @10:52AM (#43389181)
No, that's how the feature is supposed to work.

You design an abstraction which is unsafe inside, and exposes a safe API to users. That is really how unsafe it meant to be used.

Of course the standard library uses unsafe. This is where you want unsafe to be, not in random user code. That's what it was made for.

Re:Zlib-rs is faster than C by Sharlin on Monday March 17, 2025 @09:33AM (#43388447)
Yeah, but Rust just proves the point here that (doubly) linked lists

a) are surprisingly nontrivial to get right,

b) have almost no practical uses, and

c) are only taught because they're conceptually nice and demonstrate pointers and O(1) vs O(n) tradeoffs.

Note that safe Rust has no problems with singly-linked lists or in general any directed tree structure.

Re:Zlib-rs is faster than C by umanwizard on Monday March 17, 2025 @09:48AM (#43388583)
Why is it particularly funny?

C has to make a syscall to the kernel which ultimately results in a BIOS interrupt to implement printf, which you need for the hello world program on page 1 of K&R.

Does that mean that C has no abstraction advantage over directly coding interrupts with asm? Of course not.

Re:Zlib-rs is faster than C by cesarb on Monday March 17, 2025 @11:44AM (#43389729)
> C has to make a syscall to the kernel which ultimately results in a BIOS interrupt to implement printf,

That's not the case since the late 1990s. Other than during early boot, nobody calls into the BIOS to output text, and even then "BIOS interrupt" is not something normally used anymore (EFI uses direct function calls through a function table instead of going through software interrupts).

What really happens in the kernel nowadays is direct memory access and direct manipulation of I/O ports and memory mapped registers. That is, all modern operating systems directly manipulate the hardware for text and graphics output, instead of going through the BIOS.

Re:Zlib-rs is faster than C by umanwizard on Monday March 17, 2025 @12:01PM (#43389918)
Thanks for the information (I mean that genuinely, not sarcastically — I do really find it interesting). But it doesn’t really impact my point.