this post was submitted on 30 Jun 2024
284 points (95.2% liked)

Programmer Humor

19570 readers
1497 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

Meme transcription: Panel 1. Two images of JSON, one is the empty object, one is an object in which the key name maps to the value null. Caption: “Corporate needs you to find the difference between this picture and this picture”

Panel 2. The Java backend dev answers, “They’re the same picture.”

you are viewing a single comment's thread
view the rest of the comments
[–] excel@lemmy.megumin.org 32 points 4 months ago* (last edited 4 months ago) (24 children)

If you’re branching logic due to the existence or non-existence of a field rather than the value of a field (or treating undefined different from null), I’m going to say you’re the one doing something wrong, not the Java dev.

These two things SHOULD be treated the same by anybody in most cases, with the possible exception of rejecting the later due to schema mismatch (i.e. when a “name” field should never be defined, regardless of the value).

[–] sik0fewl@lemmy.ca 8 points 4 months ago (15 children)

Ya, having null semantics is one thing, but having different null and absent/undefined semantics just seems like a bad idea.

[–] Username@feddit.de 39 points 4 months ago (14 children)

Not really, if absent means "no change", present means "update" and null means "delete" the three values are perfectly well defined.

For what it's worth, Amazon and Microsoft do it like this in their IoT offerings.

[–] darvit@lemmy.darvit.nl 5 points 4 months ago* (last edited 4 months ago)

This is also how it is defined in the JSON Merge Patch RFC.

load more comments (13 replies)
load more comments (13 replies)
load more comments (21 replies)