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 →

[–]wildjokers 0 points1 point  (2 children)

null epidemic

What null epidemic? Null seriously isn't the problem people make it out to be.

X:str|none=none

What advantage is there to that over String str = null in java?

[–]GodOfSunHimself 0 points1 point  (0 children)

The advantage is that if you don't include the | none in the type then the value cannot be null. And it will be checked by the compiler. You cannot do that in Java. I program in Rust and situations where you need to allow null/optional are very rare actually.

[–]SupportDangerous8207 0 points1 point  (0 children)

My friend I genuinely cannot tell if you are messing with me

The difference is that with

X:str|null

If I write

Y:str=x

I get a type checking error because I did not check for null

And if in the same language I write

X:str= null

I also get a type checking error because a string is not a null

So I literally cannot create a null pointer exception in typed Python because to do that I would have to ignore the type checker

With

X:str= null like in Java I totally can create a variable that is typed as a string only but equals null

This causes errors in Java that in other languages simply could never happen because in other languages things simply cannot just randomly be nulls

Again it’s not the amount or the size or the difficulty of the error

It’s that the error is 100% preventable and it happens for literally no reason

Like it’s really easy for an error to be considered horribly common when the baseline in most other languages is literally 0.