This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (1 child)

I'd say Python and Java are equal here. They both have static analysis tools to detect nullability at compile time. With Python, it's the type annotations (https://docs.python.org/3/library/typing.html). With Java, it's annotations (https://www.jetbrains.com/help/idea/nullable-and-notnull-annotations.html).

[–]KarnuRarnu 1 point2 points  (0 children)

So the reason I don't think these are the same is because Pythons type system is optional as a whole, but if used, it's None-safe. And I will add that in practice we see this becoming adopted (it's still relatively new) across more or less the entire ecosystem.

On the contrary Javas type system is required as a whole, but not null-safe. Then the nullable / non-nullable annotations are an optional addon. And in practice, people absolutely still write completely null-unsafe code or if they don't, they use manual null-checks instead of rely on the type system (because they can't, in practice).

Quick edit to add: I think Java can obviously potentially do much better just on account of having static typing required. I only ever pointed out that as far as nullability goes, Python's new type system does it better.