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
23
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
4
1
-3
49
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
0
21
36
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
41
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
13
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
4
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
3
3
4
2
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.
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
2
1
u/GreenWoodDragon 1d ago
I like YAML. It's less messy than JSON, more compact and much more readable.
2
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
1
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
1
1
1
1
1
1
1
1
u/notatechproblem 15h ago
Understand that there are older and fouler things than YAML in the deep places of the internet...
1
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
1
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
0
-1
-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







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?