this post was submitted on 08 Dec 2023
623 points (96.4% liked)

Programmer Humor

32482 readers
503 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 16 points 11 months ago* (last edited 11 months ago) (12 children)

Because languages need to be able to handle the very common edge cases where data sources don't return complete data.

Adding null coalescing to a null-safe language (like dart) is so much easier to read and infer the risk of handling null than older languages that just panic the moment null is introduced unexpectedly.

[–] [email protected] 7 points 11 months ago (10 children)

For old languages, null coalescing is a great thing for readability. But in general null is a bad concept, and I don't see a reason why new languages should use it. That, of course, doesn't change the fact that we need to deal with the nulls we already have.

[–] [email protected] 6 points 11 months ago (9 children)

How are we supposed to deal with null values though? It's an important concept that we can't eliminate without losing information and context about our data.

0 and "" (empty string/char) are very often not equivalent to null in my use cases and mean different things than it when I encounter them.

You could use special arbitrary values to indicate invalid data, but at that point you're just doing null with extra steps right?

I'm really lost as to how the concept isn't neccessary.

[–] [email protected] 4 points 11 months ago

One alternative are monadic types like result or maybe, that can contain either a value or an error/no value.

load more comments (8 replies)
load more comments (8 replies)
load more comments (9 replies)