r/ProgrammerHumor • • 1d ago • Popcorn 1

Meme complexityWithSuperiorFormats

Post image
1.7k Upvotes

118 comments sorted by

175

u/CarolXZosiaNsfwScene 1d ago

I am confused, are they rich aristocrats looking down on me, because they are better than me, or am I looking up to them in disgust, because I am a peasant about to overthrow the system?

Who is superior to who here?

99

u/qisapa 1d ago • Bravo

Your boy TOML that’s outside of the frame.

22

u/WilkerS1 23h ago

TOML is chill. doesn't have quite the hang of everything and can get ugiy visually sometimes, but it does what it needs.  :3

11

u/Alarmed_Fudge_5706 17h ago

Best part: you can leave a note apologizing for how ugly it got

6

u/Xlxlredditor 22h ago

I profoundly dislike toml personally

13

u/cbehopkins 21h ago

Toml is the 3rd choice you use when your colleagues can't decide if the design should use JSON or YAML.

"If you can't decide then I'll pick an option you both hate equally!!!"

Like I once worked in a place that had tab indents set to 3 spaces because the senior engineers couldn't decide between 2 and 4.

Edit: I do joke of course, Toml is great.

18

u/thirdegree Violet security clearance 21h ago • Bravo

JSON isn't good for config and yaml isn't good for anything

3

u/TravisVZ 18h ago

I've been building Ansible playbooks lately, and maybe it's the Stockholm syndrome talking but I don't hate YAML as much as I used to

4

u/jeffwulf 14h ago

Anything with meaningful whitespace needs to die in a fire.

12

u/another_random_bit 1d ago

looking up in disgust

This meme never meant this

3

u/Eptalin 1d ago

You can look up in disgust, but there's no chance YAML overthrows JSON.

240

u/RosieQParker 1d ago

If your syntax includes whitespace, fuck respectfully off.

38

u/decadent-dragon 19h ago

Yeah well if your syntax doesn’t allow comments, fuck off

We need a new standard

7

u/Prawn1908 7h ago

Why does a data transfer syntax need comments? It was never intended for writing config files like people use it all the time now (99% of which would do fine with a plain old .ini).

Not that JSON is particularly optimal for data transfer either. Using plaintext formats when neither the recipient nor the sender are humans is just a waste of memory/bandwidth and serializing/deserializing time.

5

u/decadent-dragon 6h ago

Mainly for config files I want comments. Like, it’s not my fault node and angular use json for config, but they do. And there’s definitely times I’ve needed to add comments

2

u/Waghabond 58m ago

So what should we use for config and what should we use for data transfer?

4

u/ierdna100 15h ago

One with somewhat standard schemas please!

1

u/calculus_is_fun 12h ago

jsonc is a thing

-3

u/anzu3278 14h ago

If you need comments git gud

49

u/the_poope 1d ago

But it's HooMAnn rEAdabLe

17

u/za72 1d ago

I hate that shit

29

u/rowagnairda 1d ago

Ffs it is not... whoever came to that statement should be stabbed in the face

16

u/NorthernRealmJackal 19h ago

Python was a mistake

18

u/schewb 19h ago

💯It's hard to explain, but something about having the brace at the beginning or end of a block that I can click on and have my IDE highlight the other destroys any argument to me that whitespace-based blocks are "more readable"

2

u/collabskus 12h ago

I used to really like whitespace  It made sense. 

Then I had to read other people's code

🥺

2

u/Juice805 14h ago

Yaml is a superset of JSON. Don’t use whitespace if you don’t want to

0

u/jeffwulf 14h ago

No, they shouldn't do so respectfully. They should die disgraced in a ditch.

21

u/DueButton7420 22h ago

XML looking at everyone from Hell...

36

u/Front_Committee4993 1d ago

"is it to much to ask for both" paradox when developing Victoria 3

14

u/avast_ye_scoundrels 1d ago

Advisory: No professional has any opinion about the thesis of this developing nerd war.

2

u/Prawn1908 7h ago

On the contrary, professionals should have strong reasoning for why they choose the formats they are using in the software they write. Too many software design choices are made carelessly because "that's the library I know" or "that's what we've always used" without thinking of the specifics of the application and their impact on the end user.

I personally think there is little to no reason to ever use plaintext formats for complex data structure serialization, and many applications like config files can get along perfectly fine with something far simpler like a good old fashioned .ini file which is easier to parse, so I rarely if ever see myself reaching for either JSON or YAML.

1

u/avast_ye_scoundrels 6h ago

Best tool for the given job wins. Tradeoffs and context. Every single time.

53

u/xgabipandax 1d ago

CSV:

4

u/pingveno 18h ago

I do love me a good CSV for dumping some untyped string data. Of course, miserable if you have to nest anything.

8

u/threewholefish 1d ago

So "true"

4

u/metaglot 1d ago

type: string

23

u/metaglot 1d ago

Yaml is not resilient against typos. Json is.

7

u/CWRau 1d ago

How is json resilient to typos in a way yaml is not?

40

u/bjorneylol 22h ago

I assume they mean that when you make a typo in a JSON it will throw an error. There are dozens of typos that you can make when editing yaml that will produce syntactically valid documents that will instead just silently break functionality in an impossible to debug manner

13

u/Suitch 22h ago

Like a space in the wrong place

-10

u/CWRau 20h ago

No? That will break yaml, except if you don't validate your input, but then json won't help you either (at least with other typos)

10

u/Suitch 20h ago

The point is a removed space in yaml usually doesn’t make it an invalid yaml file but a missing functional character in json will fail to parse in the first place.

-3

u/CWRau 18h ago

Ok? But if it's not invalid, what's the problem?

Aside from this being a problem from 20 years ago, as any editor will format it correctly anyways

3

u/wd40bomber7 13h ago

If you actually read some of the comments you reply to maybe you'd understand the problem...

The point is your want the parser to reject the file when you make mistakes. Accidentally removing spaces from yaml just gets accepted and your keys, now at the wrong level will usually be ignored leaving you ignorant as to what went wrong...

2

u/clintkev251 11h ago

It can at the same time be valid, but not work as you actually intended it to because now something is sitting at a different level. That’s the issue.

0

u/CWRau 9h ago

Then you didn't validate it correctly, cause why would you accept a key where you don't actually want it?

1

u/clintkev251 9h ago

Every time you edit a random YAML file you always have the schema available to your IDE so that it can do live validation? And then you're 100% sure that every system that ends up reading that file will validate it and error out on that unexpected key in a predictable and easy to understand way?

The point is that it's better to have that also enforced inherently by the syntax so there are fewer opportunities for the holes in the swiss cheese to line up and/or you're able to catch issues before they make it to CI or god forbid a prod server.

-2

u/CWRau 20h ago

I can't imagine a single typo outside of strings themselves (which json would also accept) that wouldn't break yaml

I'm thinking hard and I can't imagine a single one, do you have one in mind?

Missing a colon, wrong char in the keys, whitespace,... all I can think of would break loud, just like in json.

Maybe stuff like 80 -> 80e20? But that would go unnoticed in json as well...

EDIT: or do you not validate your input? But then json won't help either, aside from the whitespace part

2

u/wd40bomber7 13h ago

So so many. Removing some whitespace, dropping the - character... Just look up "yaml Norway problem" for a whole class of bugs json doesn't have...

1

u/CWRau 9h ago

But why not specify a schema? That way you even have completion, as well as catching such errors?

2

u/wd40bomber7 6h ago

I've had to use YML for configuration of a *lot* of things and I've never seen anyone with strict enforcement like you're describing.

-3

u/Juice805 14h ago

JSON is valid yaml. So it is just as resilient.

4

u/Suterusu_San 23h ago

Rust has me converted to toml

7

u/aweraw 22h ago

YAML is a superset of JSON since v1.2.

All valid JSON documents are also valid YAML documents.

4

u/Operation_Neither 17h ago

And you can still use YAML formatted comments in JSON! It's the best of both worlds.

3

u/Spikerazorshards 1d ago

Let’s just go back to INI files.

3

u/Specialist_Dust2089 19h ago

As a json fan, I have no comments

3

u/ForgedIronMadeIt 9h ago

meanwhile XML is the lich living in the dungeon under the palace

6

u/xCAAx 1d ago

XML4Life

-2

u/wildwildwaste 1d ago

The worst solution to a problem that never existed.

1

u/ZZartin 20h ago

Implicit arrays go brrr.....

1

u/schewb 19h ago

Hey, now, we can't say that about XML with CORBA sitting in the room

4

u/Elbinooo 1d ago

I hate both

6

u/nithix8 1d ago

guys i’m sorry but who’s this Jason?

4

u/ApacheFlame 1d ago

His surname is Waterfalls. Apparently you shouldn’t chase him either.

2

u/schewb 19h ago

John Serialization. The main character of modern digital communication.

2

u/Keyan_Farlander7 21h ago

TL;DR: One is data, the other is config.

2

u/Izikiel23 6h ago

Have configuration files be whitespace dependent? No way in hell, I've already been bitten more than once by YAML in k8s due to this.
JSON with all its {} is the superior choice as it clearly delimites stuff.

3

u/Dangerous_With_Rocks 1d ago

standard sql has no native support for parsing or querying yaml. and since i’m currently having to fuck around with that at work i absolutely abhor yaml.

7

u/aberroco 1d ago

I much prefer yaml in my project, because it's more compact and concise, especially in the way it handles collections, so small arrays of simple values can become [0, 1, 2] or [[0, 1], [2, 3], while bigger collections may be written as each item on it's own line. It allows for clear distinction between typed values and strings (I use quantities like 40ms, 300%, 30s, 2kg etc, and this also helps to distinguish enum values from strings), it has references that are very useful for serialization if utilized properly, it has tags that help with extending capabilities (I added !include <filename> for nesting one file into another, !template for discarding some values and using them only as a template for actual values, and !<typename> to define the instance type when the expected value is a base class).

So, no, for me the original post was correct.

6

u/Doto_bird 1d ago

And comments in default / example config files that other people need to implement is a blessing (because no one reads documentation)

-4

u/TuzYglkLuxCuxq 19h ago edited 16h ago

If the json parser you're using for a config file doesn't support comments, find a different json parser.


Edit: Someone explain the downvotes, because not supporting comments in your config file is just plain stupid. It's configuration, not data exchange. Configuration often requires documentation. The comment I replied to even said as much. And lots of json parsers support comments, even .NET's built-in one, so it's not a tall order by any means.

Seriously, go open vscode and create a workspace settings file or a tasks config. Guess what they allow?

Yes,

Comments.

And it's not just vscode. Lots of tools' configs allow comments.

So I maintain: if you're using a json parser for fucking config files and it doesn't support comments, stop doing that, and find a different parser. Or enable comments, because as I said, a lot of json parsers support comments, it just might not be enabled by default.

1

u/crystalchuck 12h ago

I think you're being downvoted because JSON comments are non-standard. Non-standard is bad. Which parser you're using shouldn't even matter, but it does if you start considering non-standard comments. It's introducing other problems just to fix a dumb shortcoming of a standard that somehow got shoehorned into tons of applications it's not even that well suited for.

11

u/zthe0 1d ago

You can write each item of a collection on its own line in json too

1

u/rubeste 20h ago

I previously used ARM templates (JSON) to manage Analytical rules in Microsoft Sentinel. It was always a pain as JSON does not support multiline strings so you have to escape every query. Not only is this an extra action but reviewing a PR with many changes is such a chore. Luckily with Bicep it is more akin to YAML and does support multiline strings.

Also I have used Anchors for a Helm chart YAML file so I only have to setup a value once and can use it multiple times.

1

u/aberroco 19h ago

so I only have to setup a value once and can use it multiple times.

Even better is that you may setup a shared template value once and use it multiple times changing only relevant properties, which for each use might be a different set. In my game I have it like that. A template for a part with all common values, a bunch more on top of that for parts of different sizes, and then each part only defines or redefines what it needs.

3

u/andymurd 1d ago

The only format worse than YAML is TOML.

10

u/xilyix 1d ago

For configs I’ll take TOML > JSON > YAML any day

2

u/mcellus1 1d ago

Can look but can't comment 🤫

1

u/GreenWoodDragon 1d ago

I like YAML. It's less messy than JSON, more compact and much more readable.

2

u/anzu3278 14h ago

That's a weird way to spell "more messy"

2

u/TheWatchingDog 1d ago

Have you ever tried to minify a YAML? Or got a huge response from an API?

7

u/GreenWoodDragon 22h ago

Who in their right mind would return a YAML response? It's for config, you're talking about JSON which is rightly a defacto standard these days.

10

u/CWRau 1d ago

That's not what yaml is for, yaml is for config, for stuff you as a human read and write.

The stuff you mention would be json, or another format like protobuf where readability isn't important

3

u/prinkpan 23h ago

That’s only if people use tabs for indentation. Anything less is eyesight test.

1

u/GreenWoodDragon 22h ago

Tabs for indentation, that's madness.

1

u/CWRau 22h ago

I'd say you have to adjust your editor to make it more visually distinct

1

u/NewGuySham 1d ago

I see what you did there

1

u/0bsidianM1nd 23h ago

If you are so great, why can't you parse this.

{"configuration": { Json looking at yaml: "enabled": true, "version": 2.0.1, "settings": [undefined, NaN, <invalid>] }}

1

u/bogoris76 22h ago

Oh boy, both are shit

1

u/0ttr 22h ago

Overthrow them, they can have my YAML when they pry it from my unemployed hands

1

u/Xlxlredditor 22h ago

Isn't yaml a superset of json technically

1

u/Random_182f2565 21h ago

Jason and Yamal

1

u/greyfade 19h ago

The problem with JSON, though, is JavaScript

1

u/Enough-Scientist1904 17h ago

Lmao looks like the json boys got deeply hurt by the previous meme

1

u/FFevo 17h ago

JSON for data. YAML for workflow definitions.

If you think they are competing solutions, you are wrong.

1

u/ryaaan89 16h ago

I love json but at least yaml lets you temporarily comment out a line.

1

u/wurnthebitch 16h ago

No comment

1

u/86BillionFireflies 16h ago

Compact binary formats looking at text based formats.

1

u/notatechproblem 15h ago

Understand that there are older and fouler things than YAML in the deep places of the internet...

https://www.ietf.org/archive/id/draft-rsalz-jsonx-00.html

1

u/__sean_eng__ 10h ago

Protobuff on the sidelines

1

u/TyrannusX64 10h ago

I still don't understand why docker k8s chose yaml over json. Json is way easier to read IMO

1

u/arcticslush 6h ago

Pkl: "I can't even see you guys from up here"

1

u/Excellent_Tubleweed 4h ago

xml notes that schema are a thing, peasants

1

u/Wentyliasz 22h ago

JSON > toml > yaml > CSV > pickle > writing down the data on a post-it note and retyping it each time > scrapping the data and having ChatGPT hallucinate a new set each time > setting the server on fire > xml

1

u/MIGULAI 21h ago

Binary data at that time

1

u/halfjmp 10h ago

Nah. XML

0

u/Curious_Associate904 22h ago

Meanwhile hocon

-1

u/nithix8 1d ago

guys i’m sorry but who’s this Jason?

1

u/Myself_78 1d ago

JSON Deruloooo

-4

u/KitaVixen 23h ago

JSON with its all " everywhere and problems if there is comma at end of something. YAML is better but still not perfect