Re: Nulls vs Optional

2020-01-02 Thread Jihoon Son
I find using Optional useful and safer especially for interfaces and public methods. Even though the NPE happens very rarely in production, but we do have some in edge cases. (

Re: Nulls vs Optional

2019-12-30 Thread Gian Merlino
FYI: In https://github.com/apache/druid/pull/9111 I've used Optional a bit more; for example see HashJoinSegmentStorageAdapter#getClauseForColumn and Exprs.decomposeEquals. There are still a lot of @Nullable where needed to interact with existing interfaces. I didn't think going on a rampage

Re: Nulls vs Optional

2019-10-12 Thread Roman Leventov
Not to say that it's impossible to write exactly as fast code in Kotlin as in Java (or faster - thanks to its inline functions: https://kotlinlang.org/docs/reference/inline-functions.html), there are a few reasons why it requires greater discipline to do so in Kotlin than in Java: 1) It's

Re: Nulls vs Optional

2019-10-11 Thread Jad Naous
I don't think we need to enforce the use of Optional (at least not to begin with), but it would be a good idea to use it in new code. On Fri, Oct 11, 2019 at 6:35 AM Jad Naous wrote: > On using Optional: to me, it was mostly a documentation issue, making it > easier to no longer have to worry

Re: Nulls vs Optional

2019-10-11 Thread Roman Leventov
A few notes: (1) There is a very long-running project towards fixing static nullability problems (identified by IntelliJ). The way of fixing is always properly using/not using @Nullable and annotating all packages in the project with @EverythingIsNonNullByDefault (see

Re: Nulls vs Optional

2019-10-10 Thread Gian Merlino
For reference, a (brief) earlier conversation about this: https://github.com/apache/incubator-druid/issues/4275, which links to https://github.com/apache/incubator-druid/pull/4254#discussion_r116628607, which links to

Re: Nulls vs Optional

2019-10-10 Thread Jad Naous
On checking for existence: correct, but Guava's Optional has nice methods that allow you to easily check or set defaults etc. Can't get around that. On still passing nulls through: The assumption is that you wouldn't be passing nulls around, and null passed as a parameter to a method would be an

Re: Nulls vs Optional

2019-10-10 Thread Dyana Rose
Optional doesn't get you out of null checks when you accept them as parameters though, does it? the logic to determine if something is or isn't there still has to be written if you have conditional logic based on the existance or non-existance of the value. If an Optional is still a reference

Nulls vs Optional

2019-10-09 Thread Jad Naous
Sir Tony Hoare on inventing null while working on ALGOL (from wikipedia below): Speaking at a software conference called QCon London in 2009, he apologised for inventing the null reference :[23]