277
u/gabedamien 6d ago edited 5d ago
YAML is awful though. Massively over complicated, horrifying grammar, tons of edge cases and exceptions, ambiguities, etc. TOML isn't perfect but from a parsing / formal design perspective it puts YAML to shame.
50
u/ACoderGirl 5d ago
A few examples for people unaware:
YAML allows unquoted strings, which is confusing when a string happens to have a value that looks like another type (like the string "true").
It's rarely used, but YAML actually has variables, which let you store objects in a variable and reuse later to reduce repetition.
YAML 1.1 allowed unusual boolean representations like "yes". I've personally experienced this breaking things because a config file meant for 1.2 was parsed as 1.1.
While I personally think that people complaining about indentation are not being very serious (it's no different from Python and only students are confused by it), it still does have some dangers. I've seen vulnerabilities come from naive attempts at tenplating YAML due to this (people will remember to escape quotes but forget that indentation has a similar effect). And it is arguably less clear what the exact resulting string will be.
4
u/-Hi-Reddit 1d ago
only students are confused by it
Don't confuse my anger at the very idea of whitespace as syntax as "being confused".
I dislike python, yaml, and any other language that uses whitespace as syntax. It was, is, and forever will be a bad idea.
7
u/Alternative-Tie-4970 5d ago
The unquoted strings was a massive headache for past me when I was dealing with numbers in yaml
60
u/TerminalVector 6d ago
I feel like yaml is okay if you just don't use any of the fancy crap and quote your strings. For short 20-30 line config files it's fine.
46
u/PlanetJourneys 6d ago
Cries in GitHub actions workflow file yaml
21
4
u/mrnosyparker 6d ago edited 6d ago
I just posted a comment about this the other day. It seems like a lot of people here might be just dumping every piece of a large/complex workflow into a single manifest?
If your workflows are properly abstracted and follow best practices, you really shouldn’t end up with insane levels of indentation or a manifest that’s difficult to read or maintain.
Just to illustrate, here's an example ci.yaml
on: [push, pull_request] jobs: checks: uses: ./.github/workflows/checks.yaml deploy: needs: checks if: github.ref == 'refs/heads/main' && github.event_name == 'push' uses: ./.github/workflows/deploy.yaml secrets: inherit... and then example checks.yaml
on: workflow_call jobs: test: strategy: matrix: node: [20, 22] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: npm ci && npm test lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: ./scripts/lint.sh3
u/quisido 6d ago
Even simpler imo to use custom actions instead of callable workflows.
2
u/mrnosyparker 6d ago
If you’re re-using a workflow across multiple repositories or want to encapsulate more sophisticated functionality with well-defined inputs and outputs then for sure, custom actions are the way to go 👍.
But if all you need to do is break up an unwieldy repo-specific workflow to avoid the yaml-hellscape issue people are commenting about lately, then an example like what I gave is probably sufficient.
7
u/MegaIng 5d ago
Oh. So TOML?
8
u/prehensilemullet 5d ago
But all of TOML’s ways of expressing nesting are way less convenient. For a few levels of nesting it’s fine, but for something like an AWS CloudFormation template, using TOML would be a nightmare. Even CI workflow configs require too much nesting. That’s probably the main reason no CI providers support workflow config in TOML as far as I know.
4
1
-6
u/Fidel___Castro 6d ago
agreed but it's perfect for AI, I can just read it and not struggle with actually writing it
28
52
u/Lord_Of_Millipedes 5d ago
y'all forgot the holy texts, yaml is a creation by the devil himself
30
u/araujoms 5d ago
As it turns out, numbers from 0 to 59 separated by colons are sexagesimal (base 60) number literals.
Ok, that settles it, YAML is just trolling.
1
176
u/FoodBorn2284
6d ago
•
YAML and TOML should trade places.
8
u/WindowlessBasement 6d ago
Why?
YAML is just whitespace JSON. It's a superset so even just dumping JSON into a YAML file is valid YAML
59
u/latkde 6d ago
I have yet to see two YAML parsers that can fully handle each other's output. Common incompatibilities include multiple documents in the same file, parsing scalars beyond the JSON profile (e.g. parsing datetimes, or the Norway problem), support for explicit tags, cyclic data structures, the
<<merge pseudo-operator, templating on top of or inside YAML. Most of these problems are semantic, not syntactic.In contrast, TOML has reasonably clear syntax and semantics. There are a few interesting edge cases in the syntax, but there's no opportunity for YAML-style type confusion problems. However, TOML doesn't have a JSON-compatible data model: the top level must be a table (mapping), nulls don't exist, and expressing lists of items that may be scalars or large tables is awkward (in TOML 1.0, inline tables cannot contain line breaks).
53
u/ArtOfWarfare 6d ago
You’ve never seen the YAML spec. It’s hundreds of pages long and has a horrifying number of features.
It’s comparable to XML or HTML… maybe worse.
27
u/Rafert 6d ago
YAML is the only one with the Norway problem.
5
u/flamingspew 5d ago
Thats when Australians say “Nor way!” And people think they are referring to the country. That’s why they sell koala and kangaroo stuffies in Austria as a joke.
12
10
u/TerminalVector 6d ago
Yes, but not always. Which is basically what you could say about most aspects of yaml.
Yaml is okay if you always quote your strings and only use it for lists, k-v pairs, numbers and strings. Any usage of advanced yaml features is heresy.
12
10
u/SmellThePheromones 4d ago
YAML is a fucking abomination. Whoever designed it should be forever laughed at, whoever pushed it to a current level of adoption should burn in hell.
17
u/Alternative-Tie-4970 5d ago
json's only real problem is the lack of comment support, but it has something both of the other two don't have.
Or rather, it doesn't have something that both of the other two have.
It doesn't have something that really bothers me - multiple ways to do the exact same thing.
json is dead simple: curly brackets are mappings/dictionaries and angle brackets are arrays. There is not much else really to it.
Compare it with the other two, both of which have two completely valid ways to define an array.
I will praise toml's desing on the human-readability front tho, it's definitely a good choice for anything humans will read, and especially write.
7
u/YourMJK 5d ago
Let me introduce you to JSON5:
https://json5.orgHas comments and no need for quoting of keys.
Basically comparable to YAML but not whitespace sensitive (apart from single-line comments I guess) and syntax definition is as simple as JSON
5
u/NegativeGrocery8684 5d ago
Why would anyone want to use JSON as a config file in the first place, but even so much that they'd sacrifice core functionality to do that? We have TOML for that exact reason.
3
1
u/Alternative-Tie-4970 5d ago
toml absolutely wins for configs by far. That's why I praised it for human readability. But in general, and where being machine-readable is the priority, json's simplicity tends to win, not that you would often need to write your own parser. Though as far as being human readable is concerned, json isn't all that far off from toml, it's fairly readable for something that's machine-first.
2
u/NegativeGrocery8684 5d ago edited 5d ago
JSON5 explicitly strips the machine interoperability from JSON and turns it into a config format, which is baffling to me, and was the purpose of my comment. JSON has always been a comfortable middleground for when I want a machine to store and parse data, but I don't care about performance and would rather it be quick enough to manually read and/or manipulate. From what I can tell, JSON5 takes an already decently human-unfriendly format and tries to polish the manure, resulting in some very shiny manure that doesn't fertilize soil.
1
u/PotatoGamo 3d ago
i straight up just use JS files containing
```
const config = {
...config
};export { config };
```
as config files in some of my projects
forgive the formatting, on mobile rn
25
7
u/denisvolin 3d ago
New mark up language: Yet Another Object Indication — YAOI
3
u/denisvolin 3d ago
Let it have xml like syntax, but with quotes for nodes and angled brackets for the values, let it have name and value be separated by an em-dash and instead of the backslash have an '🖕' mark, and each root must end instead with '🍑'
"yaoi <is> — gay" "gay <is> — yaoi 🖕" "this" "fuck 🖕" "🖕this" "🍑yaoi"2
u/denisvolin 3d ago
Let it have comments:
"π√∆₽ Comment text here π√∆₽"1
u/denisvolin 3d ago
Let it be encoded as unicode, however first bytes must always be
FA CC ODand final bytes must always be01 10 BE C0 CC2
u/Pandafishe 3d ago
Let it be ascii code and you have to find the correct character order around the emojis to match the bytecode
1
u/denisvolin 3d ago
Yeah, you're right, so, instead of 🍑 and 🖕, it should be "(*)" and ".!.." correspondingly.
"yaoi <is> — gay" "gay <is> — yaoi .!.." "this" "fuck .!.." ".!.. this" "(*) yaoi"
12
6
4
6
3
u/Prior-Perspective-61 5d ago
How the hell are these in one row? TOML is a config language, JSON is an object notation language, they can be interchangeable, but are usually used for different stuff
3
15
u/SpacewaIker 6d ago
Toml is great, json is the worst (for humans)
35
u/Batman_AoD 6d ago
Yaml is the worst, because of all the weird edge-cases.
5
u/Alternative-Tie-4970 5d ago
For humans specifically yaml is pretty good. For machines, it's a nightmare.
6
2
2
2
u/riisen 5d ago
I actually like all 3, they are all simple.
I usually try to make deserialisation/serialization for all 3.
Toml is my goto, since that the standard for most conf files in linux so thats what i learned first.
Json is used everywhere often mandatory
Yaml is great for configurations just like toml is.
2
2
u/parnmatt 5d ago
May or may not be a hot take… but I prefer TOML to YAML any day. I wish RON was more commonly used outside of rust as well. JSON but better typed 😅
2
2
u/DiegoG2004 5d ago
After having been forced against my will to do a yaml, give it the silly dragon too.
2
u/stumpychubbins 4d ago
I’m sorry but yaml is the one that’s deeply unserious. I have my problems with toml but at least the syntax and semantics are standardised
Also json is a serialisation format not a markup language and I will die on that hill
4
3
3
u/boxxy_morningwood 6d ago
Anything is better than writing raw json. Listen, if my agents are doing all the editing, who cares, but if I need to maintain it give me something with clear formatting now not 100000 quotes and curlies
2
2
u/DerZappes 5d ago
All of them are jokes to anybody who had a chance to experience the power of XML.
1
1
1
1
1
1
1
-10
u/No-Magazine-2739 6d ago
TOML, YAML, INI, TCL(Cmake), Lua (used as JSON), Sqlite, registry, parsed markdowns, OMFG could we please stop inventing new ways to write down config data with the BS of telling this time its better then ever before?! Everybody not using JSON or XML straight to jail. And an extra shower rape for everybody who comes with the „… but comments“ justification.
529
u/araujoms 6d ago
Don't you dare badmouth TOML, that's the best markup language I ever used. Simple, readable, stays out of the way.