Some of us actually like the mandatory use of indentation. Just like with Python, it forces others to write in a standard way, so the result is sorta guaranteed to be readable.
Not every config file is going to be edited in a development environment. Some of the uses for yaml involve settings files, and in some cases that can involve modifying it in production, with a very basic text editor (specially on embedded systems, usually with no network connectivity at all).
Who doesn't like to count spaces when hacking on an embedded device with the barebonest editors? Especially when you only got a serial console and a limited viewport.
Seriously. Read the spec, it will take 10 minutes and then you're good for life. If TOML and YAML are hard for people I really wonder what the rest of their work looks like.
That’s not properly formatted TOML though. The whole thing would be left-justified. Plus, it’s strictly less or equally nested as JSON or YAML. Don’t like the long keys? Nest them. You’ll get YAML almost exactly. Or don’t nest them, and get something that is much more pleasant to actually review. Ever tried to read a huge YAML file? It SUCKS. Try posting this same data in YAML and tell me that it’s better.
According to Google, some people choose to format it this way to make the nesting structure clearer. Good luck trying to edit complex nested data in TOML without it.
I'm guessing your gripe with Yaml is it can be hard to find the parent of something when scrolling up?
For me this isn't a problem because VSCode keeps parent elements sticky at the top of the editor, though I know not everyone uses an IDE like that.
Which one of these alternatives do you think is better in TOML?
I'm guessing what you use TOML for usually doesn't have many levels of nesting. It's fine enough simple configs. But for structured data that's unavoidably nested, you have half a dozen ways of expressing that structure in TOML, and they're all kind of awkward. And because it's awkward, people don't use TOML for those use cases, so you don't get much firsthand experience with what it's unsuited for
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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
JSON is by far worst format of these 3 for the simple reason that it has no support for comments. Also it was never supposed to be a serialization nor configuration format. I was just something made up that worked out of the box in JavaScript.
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
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.
436
u/araujoms 2d ago
Don't you dare badmouth TOML, that's the best markup language I ever used. Simple, readable, stays out of the way.
233
u/gabedamien 2d ago edited 1d 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.
26
u/naveenda 1d ago
TOML: Tom's Obvious Minimal Language
155
u/FoodBorn2284 2d ago •
YAML and TOML should trade places.
42
u/Lord_Of_Millipedes 1d ago
y'all forgot the holy texts, yaml is a creation by the devil himself
https://ruuda.nl/2023/the-yaml-document-from-hell
26
u/PresidentOfSwag 2d ago
pyproject though
7
u/radarvan07 1d ago
Respectfully, Norway
12
u/Alternative-Tie-4970 1d 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.
6
u/Random_182f2565 1d ago
Jason, Yamal and Tom
:D
4
u/27_myths 1d ago
Eh, I'll just stick with Lisp. I don't need any of this bs!
6
u/fugogugo 1d ago
json wont get destroyed if you remove the whitespace
3
u/funny_xor_die 1d ago
You forgot to duplicate the head of JSON 10 million times
5
u/Ok_Solid6442 1d ago
hating on toml while being a yaml lover is... an opinion
14
u/SpacewaIker 1d ago
Toml is great, json is the worst (for humans)
5
u/Sibula97 1d ago
TOML and KDL are nice, and JSON has it's place.
YAML fucking sucks.
2
u/theQuandary 1d ago
All three are just worst S-expressions.
2
u/reallokiscarlet 1d ago
But... JSON is the odd one out.
2
u/riisen 1d 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
u/Prior-Perspective-61 1d 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
2
u/miller_99 1d ago
Toml is great
2
u/fwhite01 1d ago
Xaml - Not even worth to mention
2
u/pjank85 1d ago
JSON is by far worst format of these 3 for the simple reason that it has no support for comments. Also it was never supposed to be a serialization nor configuration format. I was just something made up that worked out of the box in JavaScript.
2
u/parnmatt 1d 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
u/DiegoG2004 1d ago
After having been forced against my will to do a yaml, give it the silly dragon too.
2
u/stumpychubbins 15h 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
2
u/SmellThePheromones 2h 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.
4
u/canihelpyoubreakthat 1d ago
🤡 take YAML is the devil
2
u/Brahminmeat 1d ago
TOON
2
u/SweetBabyAlaska 1d ago
YAML is utter dog shit.
2
u/boxxy_morningwood 1d 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
1
u/marcodave 1d ago
What about the TOON format?
1
u/an-italian-shotgun 1d ago
Where is XML?
1
u/pintu236 1d ago
Someon ahould make that swimming pool meme with hocon and properties as well
1
u/zeukid 1d ago
yo yo, hear me out:
toon
1
u/LukeZNotFound 1d ago
JSONC
1
u/enigma_0Z 22h ago
TOML is a just the next evolution from INI files
1
u/aceluby 22h ago
We use Hocon, like yaml but without the awfulness
1
u/Tysonzero 21h ago
Smh everyone forgetting Dhall
1
u/RickC-666 11h ago
1
u/DerZappes 1d ago
All of them are jokes to anybody who had a chance to experience the power of XML.
-10
u/No-Magazine-2739 1d 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.
-7
u/rover_G 2d ago
Tom’s unObvious Markup Language