537
submitted 2 months ago by [email protected] to c/[email protected]

Meme transcription:

Panel 1: Bilbo Baggins ponders, “After all… why should I care about the difference between int and String?

Panel 2: Bilbo Baggins is revealed to be an API developer. He continues, “JSON is always String, anyways…”

you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 17 points 2 months ago
[-] [email protected] 10 points 2 months ago

If there are no humans in the loop, sure, like for data transfer. But for, e.g., configuration files, i'd prefer a text-based solution instead of a binary one, JSON is a nice fit.

[-] [email protected] 8 points 2 months ago* (last edited 2 months ago)

What, no! Use TOML or something for config files.

[-] [email protected] 6 points 2 months ago

TOML

Interesting... me likes it.

[-] [email protected] 2 points 2 months ago

Yaml is more human readable/editable, and it's a superset of json!

[-] [email protected] 1 points 2 months ago

Until someone cannot tell the difference between tab and space when configuring or you miss one indentation. Seriously, whoever thinks indentation should have semantic meaning for computers should burn in hell. Indentation is for us, humans, not computers. You can write a JSON with or without indentation if you want. Also, use JSON5 to have comments and other good stuff for a config file.

[-] [email protected] 1 points 2 months ago

Yaml is just arcane bullshit to actually write as a human. Nor is it intuitively clear how yaml serializes.

[-] [email protected] 0 points 2 months ago

Yaml is cancer.

[-] [email protected] 1 points 2 months ago

What I'd like for a configuration language is a parser that can handle in-place editing while maintaining whitespace, comments, etc. That way, automatic updates don't clobber stuff the user put there, or (alternatively) have sections of ### AUTOMATIC GENERATION DO NOT CHANGE###.

You need a parser that handles changes on its own while maintaining an internal representation. Something like XML DOM (though not necessarily that exact API). There's a handful out there, but they're not widespread, and not on every language.

[-] [email protected] 0 points 2 months ago
[-] [email protected] 1 points 2 months ago

Is a very good idea providing much needed fixes to the JSON spec, but isn't really what I'm getting at. Handling automatic updates in place is a software issue, and could be done on the older spec.

[-] [email protected] 4 points 2 months ago

If you're moving away from text formats, might as well use a proper serialisation tool like protobuf...

[-] [email protected] 3 points 2 months ago

Hell, no. If I wanted to save bytes, I’d use a binary format, or just fucking zip the JSON. Looking at a request-response pair and quickly understanding the transferred data is invaluable.

[-] [email protected] 0 points 2 months ago
[-] [email protected] 0 points 2 months ago

For the love of all things pure, holy, and just, please do not use YAML in your APIs...

[-] [email protected] 1 points 2 months ago

Fine, and if you don't use json in your API because of the deficiency highlighted in the meme, what format do you use in your API?

[-] [email protected] 1 points 2 months ago

I use JSON. I have used Avro for things in Kafka but I'm not sure the benefits outweigh the negatives. Avro is much more complicated than people think and most folks don't really have a strong desire to learn how it should be used and do stuff incorrectly. Everybody knows JSON and it works with everything though. (Example: so many people just hear that Avro schemas can be backwards compatible but have zero idea that you still need the schema that wrote the message even if you want to read it into a newer one.)

Interestingly, I take the meme as saying a dev is using the wrong types in their serialization format (using strings to store integers) which was my biggest problem with Avro. Mostly from people not using logical types or preferring to use ISO 8601 datetime strings instead of the built-in timestamp-millis type.

this post was submitted on 30 Jun 2024
537 points (98.0% liked)

Programmer Humor

19187 readers
1374 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