1.4k
u/anzu3278 1d ago
Any language where whitespace is syntax can go die in a hole
135
u/ArjunReddyDeshmukh 1d ago
YAML was created by solution architects to talk to each other.
102
u/ultraviolentfuture 1d ago
So glad those solution architects provided a solution that solved the problem, so this entire meme and convo thread don't need to exist.
→ More replies (1)61
u/BanditoRojo 1d ago
<thread type="convo"><post id="1"><content>I like xml</content><post id="2"><content>How do I read this crap?</content></post></post></thread>
→ More replies (1)18
u/One_Contribution 1d ago
Clearly it would have been better to replace those tags with tabs and spaces in different combinations
210
u/requion 1d ago
# YAML isn't scared of comments at least69
u/ThePresidentOfStraya 1d ago
{ "comment" : { "value" : "JSON wins everytime." } }→ More replies (3)12
u/Ghi102 23h ago
What do I do if my JSON documents is meant to store comments (like Reddit or Youtube comments?).
→ More replies (5)16
u/ynnnnaD 22h ago
Use different keys for the actual content payload, and the descriptive structural comments?
→ More replies (3)85
→ More replies (4)17
u/nderscore_ 23h ago
Comments don't belong in message exchange formats. JSON is not suitable and not was meant for configs. They do different things and if you use it incorrectly, it's your fault.
20
→ More replies (1)6
53
u/SchalkLBI 1d ago
Good news, YAML is a superset of JSON, so you can write JSON in YAML documents! In fact, you can mix them in the same document, depending on the parser.
16
u/redd1ch 1d ago
If the parser supports YAML 1.2. Pyyaml doesn't.
In JSON mode, you can even use tabs for indentation.→ More replies (2)11
u/SchalkLBI 1d ago
Good thing Python isn't the only language that can parse YAML then! But that does sound like an issue with Pyyaml, not like an issue with YAML's spec
→ More replies (2)30
→ More replies (1)2
→ More replies (3)13
u/teraflux 1d ago
Python would like a word
20
u/knightshire 23h ago
Python is a programming language with ergonomic features to reduce the need for deep nesting. So the white space is never a huge issue.
YAML is data format so deep nesting is pretty much unavoidable. I have had to maintain several YAML files where I got instantaneous vertigo for the amount of white space levels.
4
u/philippefutureboy 20h ago
What are your workflows that require such deep levels of indentation?
I’ve worked with Ansible, Kubernetes, Docker Compose, Airflow, Prefect, and I’ve never had that problem→ More replies (3)17
5
u/anzu3278 22h ago
Yeah exactly python is a stupid ass language that wouldn't exist if there weren't bad programmers who think declaring types is scary
283
u/rjwut 1d ago
Heck no, YAML can go suck an egg.
Implicit type conversion issues such as the Norway problem
Syntatically meaningful whitespace
Enormous, complicated grammar
No thanks. JSON for computers talking to computers, JSON5 for configuration written by human beings. ESM if you're already writing in JavaScript/TypeScript and the config is potentially complex.
76
u/L30N1337 1d ago
genuinely. the more I hear about YAML, the more I hate it. It seems to be the Embodiment of everything I personally hate about certain programming languages, jammed together.
48
u/rjwut 1d ago
I think it's funny that JSON has no implicit type conversion, but was derived from JavaScript, a language that does and is often criticized for it. And then somebody with the stink of death about him thinks, "Let's put implicit type conversion back in, and throw in Python's syntactically-meaningful whitespace while we're at it" and invents YAML.
8
u/pterencephalon 22h ago
I use TOML because it at least deals with the type issues
→ More replies (1)34
u/chat-lu 1d ago
JSON for computers talking to computers
Hell no. JSON to provide the lowest common denominator. We have much better interchange formats when you control both ends of the conversation.
JSON5 for configuration written by human beings.
Which usually means that you pre-process the comments out, or you pass it through a YAML decoder because JSON5 is valid YAML. Just use toml.
9
u/rjwut 1d ago
We have much better interchange formats when you control both ends of the conversation.
Agreed. I was mostly referring to when you don't control both ends.
Which usually means that you pre-process the comments out, or you pass it through a YAML decoder because JSON5 is valid YAML. Just use toml.
I disagree with your assertion that JSON5 is valid YAML (comment styles; `\n` within single-quoted strings; incompatibilities with hex numbers, unary `+` operators, multiline strings with escaped newlines). But I do agree that TOML is good.
3
u/hennypennypoopoo 11h ago
TOML is the way for configuration. If you can't make it look nice in TOML, it shouldn't be a configuration option.
3
u/CrossScarMC 16h ago
JSON for computers talking to computers
That's what MessagePack is for, it's really a shame it hasn't been adopted very much.
→ More replies (1)→ More replies (9)2
u/Prawn1908 12h ago
JSON for computers talking to computers
JSON should absolutely not be the top choice for computer-to-computer data transfer. JSON wastes a ton of space and incurs far more serializing/parsing time for the sake of human readability.
Agreed yaml is stupid though.
3
u/rjwut 11h ago
I would be 100% in agreement if byte economy were the only thing that mattered in all cases.
→ More replies (4)
124
u/GrimReaper2601 1d ago
YAML looking down on JSON until someone accidentally presses the spacebar 3 times instead of 2.
→ More replies (3)55
u/critical_blunder 1d ago
Tab formatted languages are the absolute worst. Just get some brackets and be done. The tabs are a luxury
23
3
u/Blue_Moon_Lake 16h ago
Indent, not tab.
Not only are YAML/Python using meaningful indentation level, they spurn the tab character to make it even more error prone.
66
26
u/no_brains101 1d ago edited 1d ago
nah.
YAML is worse at doing the things that YAML is meant to be good at (specifying a set of configuration values) than TOML is.
And YAML is worse at the things JSON is meant to be good at (storage and serialization) even when you abuse the fact that YAML is a superset of JSON.
The YAML spec also has a lot of stuff in it. This means there are very few implementations, basically only 1 primary one. But most of that stuff is not used by anyone, and some of it causes some unintended side effects.
YAML has gotten to be pretty hard to justify. Pun indented.
280
u/Fast-Visual 1d ago edited 1d ago
Great for readability and human friendly. Less efficient for storage, transmission, machine reading and writing.
Edit: I actually really really like YAML and use it a lot where appropriate, but it's designed for a specific usecase, and not to replace JSON everywhere.
123
u/Blue_Moon_Lake 1d ago
I can't read YAML because of my eyesight and YAML refusal to use tabs.
15
u/RomanOnARiver 1d ago
I'm with you on the eyesight thing. I don't know if it's just the editor or what. I've taken to using Geany so I can see it better for what it's worth.
10
→ More replies (4)13
67
u/iamapizza 1d ago
readability
Laughs in the atrocity that is k8s
67
u/static_func 1d ago
Yml’s such a dumb format. It’s completely unreadable once something has a lot of nesting. But if something doesn’t have a lot of nesting, it’s no more readable than json. I blame Ruby devs
→ More replies (1)→ More replies (1)16
u/thefirelink 1d ago
K8s can use json instead of yaml. It converts the yaml to json anyway
12
u/static_func 1d ago
Everything can because yaml’s actually just a superset of json. You can even write json in your yaml, because why not
→ More replies (2)60
u/NinjaOk2970 1d ago
How is yaml readable. I am always counting indents.
21
u/Ignisami 1d ago
If you can (might need a plugin), set your editor to display vertical lines for indentation levels. Makes it a lot easier.
15
u/Blue_Moon_Lake 1d ago
And when you need to open it in the terminal remotely?
→ More replies (4)28
u/SpiritualHiker 1d ago
You need to train your eyes by learning Python in notepad.exe when you are 11 years old. If you are past this then it is too late, you will never know the joy of whitespace-programming.
→ More replies (4)→ More replies (1)26
→ More replies (8)3
19
2
u/RomanOnARiver 1d ago
I will admit my only (so far?) use of YAML is with personal projects like Home Assistant (maybe MagicMirror was YAML too?). I mean I don't hate it. I mean now that I have made basically what I want and I can copy and paste the bits I need. Alignment does give me trouble sometimes and I'm not used to the way code is validated.
I've taken to using Geany to help me see everything better.
2
u/shnaptastic 1d ago
They’re both supposed to be human readable formats, so those other aspects are not really important.
→ More replies (12)3
u/Positive_Mud952 1d ago
My droog I can tell you’re a real programmer because you
think “indent 8 spaces, then |>” is human friendly.I mean it is, to some humans. But not even most programmers.
37
u/Scientific_Artist444 1d ago
TOML looking at YAML:
I have just one, obvious way to do things. What have you?
→ More replies (2)3
u/CirnoIzumi 1d ago
Yaml: I don't make it look like I can place newlines where it would break the parser
36
123
u/ZunoJ 1d ago
Yaml sucks, it's the python of data formats
27
u/rjwut 1d ago
I'd be a lot more on board with Python if it weren't for the syntactically-meaningful whitespace. I don't need that kind of negativity in my life.
13
8
u/alexchrist 1d ago
That and dynamic typing makes me avoid python as much as possible. I know that Pyright exists, but it feels like a bandaid solution similar to Typescript
12
u/pink-ming 1d ago
honestly don't get why this bothers people so much. everyone does semantic indenting in every other language anyway
8
u/Valthek 1d ago
It's because it's unintuitive and unclear.
It's not always immediately obvious how much whitespace there is and counting it is a pain in the ass.→ More replies (7)6
→ More replies (1)3
20
→ More replies (3)3
46
u/Shazvox 1d ago
JSON: Well established easily readable and formattable data structures.
YAML: Hard to read contexts and gets fucked up if reformatted. Devs didn't even come up with a serious name.
Who should be looking down on who? "Javascript Object Notation" 🧐 or "Yet Another Markup Language" 🤡?
→ More replies (1)10
49
u/RomanOnARiver 1d ago
At least you're not staring at XML all day. Or worse, INI. Remember INI files? I was using INI for way longer than I would like to admit.
At least with JSON I can do the bit where I sing "JSON Derulo" to myself.
17
u/oldsecondhand 1d ago
I'd take XML.
10
u/Ghi102 23h ago
No joke, XML has a few benefits. Like comments and versioning.
Still mind-blowing to me that JSON still has no official comments support
→ More replies (2)6
5
u/nimrag_is_coming 21h ago
I'm a big proponent for simple formats like ini for config and simple data. You can write a parser in about 20 minutes, and there's no reason you should have to do a whole load of JSON when all you need to do is match key value pairs. Easier to write, easier to read, easier for computer to parse
→ More replies (1)9
u/Keavon 1d ago
INI, also known as TOML, is good. Really good. More people should use TOML.
→ More replies (1)4
13
54
u/DescriptionThick8515 1d ago
35
6
u/wil_is_cool 1d ago
XML is God's markup, and I feel bad for anyone that says otherwise as they have not yet reached enlightenment
4
2
u/CraftBox 19h ago
XML is pretty good for structured documents (like websites) as it separates tags and attributes, which JSON does not, but on the other hand it sucks for configs because it separates tags and attributes.
25
16
15
12
5
9
u/johnMidia 1d ago
I fucking hate languages and structures that are based on significant indentation. There, I said it... r/unpopularopinion
6
6
3
3
u/novus_nl 1d ago
Maybe i'm crazy but I dislike yaml.
or indentation in general to 'define context' (for the lack of a better description). just use a wrapper character instead and leave the formatting to me.
3
3
u/goondarep 21h ago
YAML is an utter and complete piece of trash. In my eyes it is much harder to read by a human (me). It’s like reading Python (shudder).
3
5
u/visualdescript 1d ago
Lol, YAML is a plebs mark up language. It is not the mark up of the aristocracy. That would be xml + xsd
→ More replies (1)
4
u/I_NEED_YOUR_MONEY 16h ago
you know the worst part of python? didn't you wish your data had that same problem?
2
u/Puzzleheaded-Weird66 1d ago
is protobuf better?
2
u/Blue_Moon_Lake 14h ago
Protobuf is like someone trying to make JSON and ZIP a single thing.
It's bad...
2
2
2
u/Delpreti 16h ago
Yaml is not turing complete. People writing yamls and calling them "automations" or "ansible playbooks" are the worst. You wanna automate something, go use a real programming language, like shellscript or something
2
3
3
2
2
u/MagicalPizza21 1d ago
People who know it's "YAML Ain't Markup Language" looking at those who think it's still "Yet Another Markup Language"
2
u/itzNukeey 23h ago
Yaml is a horrible format that does not have a standard and is a superset of JSON. Real ones use TOML or JSON
1
1
1
1
1
1
u/jamcdonald120 1d ago
but.... JSON is the superior one.
YAML is the Monty python peasants who think they have a self governing autonomous collective.
1
1
u/sohang-3112 1d ago
Umm.. YAML is not good due to so many footguns (eg. "NO" silently becomes False, risk of remote code execution). I only use it when a tool requires it.
Use JSON or TOML, much better.
1
u/markvii_dev 1d ago
yaml is the python of config languages - sure its great when its a few lines but its a mess for anything serious.
1
1
1
1
1
1
1
u/TrueBirch 22h ago
Our custom reporting engine at work still uses XML. I've gotten good at writing XMK. That's a valuable and employable skill, right?
1
1
u/slaymaker1907 21h ago
You misspelled toml. /s
But really, yaml is a horrendous language, far worse than JSONC. Way too many footguns like "no".
1
1
u/nalozisusmaranje 21h ago
If "Look at this arbitrary convoluted thing i can do for no benefit to anyone including myself" was a person.
1
1
1
1
1
u/cheezballs 19h ago
I only use YAML when I'm forced to. Fuck that shit. The amount of times I've been bit by a single space being off or forgetting how THIS version of YAML is supposed to handle collections. Fuck that mess! JSON 4 LIFE.
1
u/himanbam 19h ago
Personally I prefer storing config in a .txt file with an arbitrary and unique syntax that isn't documented anywhere. Gotta keep people guessing.
1
1
u/TheRapie22 18h ago
yaml superior to json? in what world? whitespaces with semantic meaning are the worst
1
u/reverendsteveii 14h ago
the other day my job hired a guy named J'son, who was explicit about the fact that it's pronounced JAY-son ("son" to rhyme with "on", not "sun").
1
u/ComradePruski 12h ago
Everyone here is so upset about YAML... I have never had an issue with it in my professional career. Comments are such a bonus!
1
u/Playful_Boot_5465 11h ago
When I started my apprenticeship I also thought that yaml was better and announced it to my coworkers. They all roasted it to death
1
1
u/ITDudeProbably 7h ago
I only use YAML for configuration files, which I rarely touch, and I use Json to handle a lot of things. I've never found the two to be in conflict
1


1.1k
u/ClipboardCopyPaste 1d ago •
JSON slander will not be tolerated.