this post was submitted on 05 Sep 2024
55 points (92.3% liked)
Programming
17313 readers
95 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The items don't seem concise and always clear. But seems like a good, inspiring resource for things to consider.
I've never heard of evading null with a Null object. Seems like a bad idea to me. Maybe it could work in some language, but generally I would say prefer result typing. Introducing a result type wrapping or extending the result value type is complexity I would be very evasive to introduce if the language doesn't already support result wrapper/state types.
This is quite standard, and in fact it's even a safety feature. C++ introduced nullptr defined as an instance of std::nullptr_t explicitly with this in mind.
https://en.cppreference.com/w/cpp/language/nullptr
This approach is also quite basic in monadic types.
With what in mind? Evading
NULL
?Languages that make use of references rather than pointers don't have this Dualism. C# has nullable references and nullability analysis, and
null
as a keyword.What does your reasoning mean in that context?
It's not about references vs pointers. You could easily have a language that allowed "null references" (edit: too much C++; of course many languages allow null references, e.g. Javascript) or one that properly separated null pointers out in the type system.
I agree with your point though, using a special
Null
value is usually worse than usingOption
or similar. Andnullptr_t
doesn't help with this at all.