3 ms·
Safety is a feature and that null check prevents bugs. I'd rather have slow but safe code rather than fast but buggy code.
by stuff4ben 6y ago
Safety is a feature and that null check prevents bugs. I'd rather have slow but safe code rather than fast but buggy code.
- pmart123 6y agoAdding checks creates more code branches and tests. Passing null in is the bug.
- freemint 6y agoCan you show it has any impact on benchmarks? This is something speculative execution should take care of that quickly? "Premature optimization.... " you get the drift.
- Sohcahtoa82 6y agoIf the null check silently ignores the attempt to remove a non-existent item from the list, then the null check did not prevent a bug, it merely hid it. IMO, even though this is C, the Zen of Python still applies, which states: > Errors should never pass silently unless explicitly silenced. Its the caller with the bug, not the library code.
- ninkendo 6y agoCan we all at least agree that if the language could express non-nullable pointers, we'd all be better off? (Something like `Option<T>` in Rust, or Swift's `?` sugar for their `Optional`, etc etc) Then the type of the function would just declare a that the pointer can't be null, and code which sends a nullable pointer would refuse to compile.