Hacker News new | ask | show | jobs
by siwatanejo 1465 days ago
> 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.

4 comments

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?
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.
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.
It can if you choose to return Optionals instead of nulls.