Re:Cold Showers
by siwatanejo on Saturday June 18, 2022 @08:38PM
(#31795107)
> A type system can keep you from having to write those tests.
Because with a proper static lang (hint: not Java, not C#), nil doesn't exist? Right.
Those languages don't have null safety, but plenty of languages do. Rust, Kotlin, Swift, Haskell, etc.
The claim is true: a type system _can_ prevent null-related issues and eliminate the need to account for them in tests. That's not the same as saying every type system does.
Doesn't C# support this by enabling Nullable?
Re:Cold Showers
by creakingstairs on Saturday June 18, 2022 @09:48PM
(#31795412)
They all have nulls but a static lang will warn you that the value can be null.
This is false. There are plenty of languages without pervasive implicit nullability. Check out Haskell and Rust and Ocaml.
Re:Cold Showers
by creakingstairs on Saturday June 18, 2022 @11:53PM
(#31796015)
You are right. I should have said some. The point I wanted to make was that having type safety is better for checking null than having no type at all.
Re:Cold Showers
by shepherdjerred on Sunday June 19, 2022 @01:21AM
(#31796362)
It can if you choose to return Optionals instead of nulls.
A type system can keep you from having to write those tests.