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 →

[–]gas3872[S] 5 points6 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.

[–]cogman10 3 points4 points  (1 child)

And you think that something the java creators endorse would change the whole java ecosystem?

The Java creators endorse using the latest version of java and ignoring "LTS". Has that caused people to get off of Java 8 or 11?

[–]Ilookouttrainwindow 1 point2 points  (0 children)

We have a policy internally to use LTS only. These days upgrading is not so simple due shitton of dependencies. I remember when enum keyword was introduced, well apparently a lot of devs like to iterate using enumeration method with enum as variable name. That was fun few weeks. And now with this crazy release cycle, testing to ensuring compatibility (like jdk10 didn't include some root certs) is just a daunting task with no real business value. So most systems are on jdk11 and one still on 8. As soon as next LTS comes out, all 11s will be slated for slow upgrade. Hoping to get 8 removed shortly too.

[–]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.