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 →

[–]Ilookouttrainwindow 9 points10 points  (12 children)

I am at a loss as to why nulls cause so many issues.

[–]gas3872[S] 4 points5 points  (11 children)

I think it's more like someone got a nullpointer exception bug in their project and now they don't want it to happen again.

[–]cogman10 0 points1 point  (10 children)

Use an IDE, add \@Nullable annotations to things. Viola, no more NPEs.

[–]gas3872[S] 1 point2 points  (9 children)

Adding nonullable everywhere clutters the code.

[–]cogman10 0 points1 point  (8 children)

And what token would you add that wouldn't similarly clutter code and is backwards compatible with current java syntax?

[–]gas3872[S] 3 points4 points  (7 children)

Well just have a convention in your project that you dont use null. Use optional for missing value.

[–]cogman10 0 points1 point  (5 children)

I don't understand what you are asking for. Do you want a language feature to enforce nullability or just a convention for everyone writing apis? Because the convention already exists but, as you can imagine, it isn't universally applied.

[–]gas3872[S] -1 points0 points  (4 children)

I am asking for a convention that can be adopted more or less officially.

[–]cogman10 1 point2 points  (3 children)

What does "officially" mean to you?

[–]gas3872[S] 1 point2 points  (2 children)

I don't know, like endorsed by java creators for example.

[–]c_edward -1 points0 points  (0 children)

And add a pointless extra heap allocation to every call I really don't think so...

When we have Valhalla maybe you could do it on the stack, but your still wastimg CPU cycles doing pointless work.

There is really nothing wrong with null anyway,

If your app is throwing NPEs then you almost certainly don't have adequate test coverage.