News for hackers. Stuff that matters.
Re:I stopped everything and started writing C again by davedx on Wednesday March 12, 2025 @06:26PM (#43348318)
This is objectively nonsense
Re:I stopped everything and started writing C again by codr7 on Wednesday March 12, 2025 @08:25PM (#43349173)
Interesting use of the word 'objectively' there.
Re:I stopped everything and started writing C again by davedx on Thursday March 13, 2025 @04:05AM (#43351163)
How can it not be true? One of the primary features of the rust compiler is enforcing memory safety at compile-time. C doesn't have anything like that. There are an entire class of bugs that are impossible to implement in rust.
Re:I stopped everything and started writing C again by stouset on Thursday March 13, 2025 @10:34AM (#43353801)
Not really.

I have written a lot of C and Rust. The notion that identical projects written in both languages would have identical numbers of (or even severity of) bugs is laughable on its face.

I mean, literally just not being able to deref a NULL pointer by itself is enormous.

Re:I stopped everything and started writing C again by tialaramex on Thursday March 13, 2025 @11:53AM (#43354528)
You can dereference null pointers in Rust, it's also easy to make null pointers. The thing is I'm not surprised you didn't realise this is possible because you would never actually do this in Rust since it's obviously a bad idea.

  let p: *const i32 = std::ptr::null();  // Pointer to a signed 32-bit integer, but it's null
  unsafe { some_local = *p };            // Dereferencing the null pointer, bang
If we instead use references they're nicer to work with, don't need unsafe, perform the same, and are never null. So obviously that's what real Rust programmers almost always do.
Re:I stopped everything and started writing C again by stouset on Thursday March 13, 2025 @01:04PM (#43355224)
Of course it’s possible. I am well aware it’s possible. You can also just call into a C library that hands you a null pointer. Further, it’s wholly possible to invalidate every single one of Rust’s safety guarantees if you try hard enough.

In practice I have never encountered a null pointer in Rust. Most Rust programmers have never encountered a null pointer. For most non-FFI practical purposes you can act as if they don’t exist.

Re:I stopped everything and started writing C again by wiseowise on Thursday March 13, 2025 @01:49PM (#43355675)
>> One catches far more issues than another

> akshually they have same amount of bugs

You literally segfault by dereferencing invalid pointer.

Re:I stopped everything and started writing C again by dannymi on Thursday March 13, 2025 @03:19PM (#43356422)
I agree.

But: If you are LUCKY! The worse case is if you DON'T segfault by dereferencing invalid pointer.