3 ms·
From your OC: > Null is fast. Super fast. Literally free. Yes and: The JIT will optimize away Null Object method invocations. All my composable classes have
by specialist 3y ago
From your OC:
> Null is fast. Super fast. Literally free.
Yes and: The JIT will optimize away Null Object method invocations.
All my composable classes have a Null Object. No null checks means concise iteration (eg graph traversal). Eliminates NPEs. Just as fast.
Win / win / win.
Optionals (classes and operators) continue to be turrible mistakes. So much unnecessary effort, so little benefit.
Ditto @Nullable and @Nonnull.
Someday, maybe, I'll make a javac compiler plugin which autogenerates Null Object implementations and converts "Node abc = null" to "Node abc = Node.DEFAULT_NULL_OBJECT_INSTANCE".
https://en.wikipedia.org/wiki/Null_object_pattern https://en.wikipedia.org/wiki/Null_object_pattern
- anonymoushn 3y agoIt seems like when one is implementing Null Objects and making incomplete attempts to prevent values from ever being null it is not really an argument in favor of nullable values being good and the only type of values that should be present in a language.
- specialist 3y agoI'm not smart enough to parse this. Try again?
- anonymoushn 3y ago"All non-primitive values are nullable references" is a feature of the language. You posted that you are trying to avoid using that feature (instead using non-null references to a special Null value?) and trying to avoid having null references for the types you create. It seems like you do not actually think the feature is a good feature.
- specialist 3y ago> Ditto @Nullable and @Nonnull. I was referring to the annotations. My proposal moots them. References would still be nullable.
- anonymoushn 3y agoCan you explain why it is good that null is a valid value for your types at the same time as you are trying to prevent them from ever containing that value?
- specialist 3y agoYou're overthinking this. Semantics of 'null' are the same. Underlying implementation is different, better.
- anonymoushn 3y agoIf the semantics were the same, you wouldn't need a replacement and all your proposed changes would have no observable effect on the behavior of any program.
- specialist 3y agoSemantics != behavior. In truth, I'm having hard time deciding if you're trolling or actually truly, sincerely not understanding this. Read the wiki page. Implement a few Null Objects. If you still have questions, about this trivial concept, then I'll be happy to go a few more rounds.