News for hackers. Stuff that matters.
Re:Falsehoods programmers believe about null pointers by LorenPechtel on Monday February 10, 2025 @05:40PM (#43006216)
You're assuming that you can always make your declarations correctly express whether something can be null. Let's consider a real world example I hit: Every cell has a concept of it's neighbors. Now, the world isn't infinite, some of those pointers are null. But there's a boundary layer of edge-of-the-world cells to keep you from going too far.

Thus, in the real world null can never occur--but there are a gazillion places where it would have to test for a null that should never happen. Or simply Assert in the routine itself.

Re:Falsehoods programmers believe about null pointers by gwbas1c on Monday February 10, 2025 @11:05PM (#43008826)
> You're assuming

I'm not. It's pretty clear that you don't know how null safe Swift, C#, and Rust work.

IE: Rust has the option type for when a value can be null, and the compiler forces you to do an "empty" check. Otherwise, null, does not exist in the language.

Swift and C# are more metadata based. You indicate if a value supports null or not. The compiler will give you a warning, or error depending on configuration, if you try to assign null to a value that does not expect it.

All three languages have a concept of values that can be null, (or empty in Rust if you want to argue semantics,) so your type system tells you when a value can be null, or when it is expected to not be null. In all three languages, the compiler can force you to make assignments before you use an object.

Re:Falsehoods programmers believe about null pointers by gwbas1c on Monday February 10, 2025 @11:15PM (#43008892)
In Rust, you use https://doc.rust-lang.org/std/option/ when a value could be "null", otherwise a value is never null.

C# has https://learn.microsoft.com/en-us/dotnet/csharp/nullable-ref...