News for hackers. Stuff that matters.
Re:Show HN: Zero-dependency Java framework out of beta by jen20 on Monday September 25, 2023 @04:01PM (#37649752)
> The real nice thing about Java is everything is statically typed

Optional and generics would like a word...

Edit: OK, since this got a downvote, let me be clearer, with some help from the parent:

You just use Optional<T>, and if you're lucky some of your dependencies BUT NOT ALL OF THEIR TRANSITIVE DEPENDENCIES also use Optional<T> correctly and don't return null, and before you know it you've lost the nice safety and it's a crapshoot whether your Optional<T> will be null.

Re:Show HN: Zero-dependency Java framework out of beta by galdosdi on Monday September 25, 2023 @04:21PM (#37650041)
Yep, this is a great point, and while these days people use stuff like @NonNull/@Nullable, it does not help a lot, for the exact same reason.

I wish Java had had non nullable types as default from the getgo, and it's hard to add now for the same reason JS/PY have a hard time adding static typing

Re:Show HN: Zero-dependency Java framework out of beta by kaba0 on Monday September 25, 2023 @04:14PM (#37649950)
I have never ever ever seen a null inside an Optional -- the most common constructor actually Optional::ofNullable makes the correct decision, so you can't even fck it up, and if you deliberately try to, I'm sure intellij would scream your head off.
Re:Show HN: Zero-dependency Java framework out of beta by jen20 on Monday September 25, 2023 @04:19PM (#37650015)
The problem is whether the optional itself is null, not whether the contained value is.
Re:Show HN: Zero-dependency Java framework out of beta by kaba0 on Monday September 25, 2023 @04:22PM (#37650062)
That’s not a problem either.
Re:Show HN: Zero-dependency Java framework out of beta by waynesonfire on Saturday September 30, 2023 @12:37PM (#37717110)
The reason you've never seen it is because it won't let you,

private Optional(T value) { this.value = Objects.requireNonNull(value); }