YAML: Probably not so great after all
arp242.net
arp242.net
Still, totally fine for pretty much everything I’ve needed it for.
Maybe I'm just not that ambitious and haven’t hit any of the corner cases pointed out in the article.
Have been using it as a html forms definition language for 7 years - with great success.
So, yes, maybe not so great, but also not too bad.
Try writing non-trivial multi-line bash snippets for Gitlab CI in yaml. These change your opinion very fast.
2. “In yaml” could be a fun way to end all kinds of sentences describing challenging tasks ;)
Other part of the world might not like too many levels of indirection, and would consider their approach a good practice.
I still don't like YAML though
1. Lint the code using ShellCheck, which IMO is essential for any shell
2. Run and test that code locally, or anywhere outside of the CI tool
It’s only marginally less convenient to externalise the code into a .sh file and load it in CI.
Or you can collapse all the groups in your text editor and usually easily see what level you're at
But I still don't think there's any desirability for whitespace significance in code. Is there any problem it solves that isn't better solved by having enough structure and standardized tooling for autoformatting like go fmt?
SPace is for separating words.
Modern editors (and old ones too) should be able to show what is a TAB, so there is no reason to be confused.
The problem is that people think of TABs as a certain number of spaces, as if an indentation must be a certain number of spaces. In Python or Yaml etc, the logical construct is to have "one indentation level" for things like the statemants that belong to an if, or whatever. Requiring people to put in a somewhat randomly chosen number of spaces is just silly. It is "one level", so the logical choise would have been to put in one symbol to designate this fact, then use the settings of the editor to show it as you want (how many "spaces" to move), and this can change depending on personal choice, the monitor you use, etc.
The TABualator key was invented for this purpose, in the age of the typewriter, to make things visually stand out by grouping it in the same column of a table. So all the lines that belong together are listed with the same indent, (originally all items belonging in the same column being listed under the same heading).
Example
user:
given_name: something
family_name: somenting
Using a somewhat randomly number of spaces is just silly, the two name lines is one hierarcical level below "user" so add one tab char to represent that fact.
Then you can vary the visual representation in your editor to your liking.json is created to make it easy for machines to parse, not humans. Leave it to the machines.
Actually: one of the reasons TABis misunderstood is that cheap typewriters didn't have adjustable tabulator positions, and when computers came along it was often implemented with fixed columns (typically every 8), so people think of TAB as 8 spaces, which often is not what you want.
In C you actually use indentation when you write code to make it readable for humans, but the machine doesn't care, so there is a disconnect between the visual and how it is parsed.
You have to both use indentation add a lot of curly-braces to your code. In Pyhon you don't have this double-work.
If you truly needs user-configurable setting, maybe TOML is for you.
That is…not remotely the holy grail. You’re really throwing out the baby with the bathwater on that one. User-configurable settings are important for many, many applications.
In the narrow case that you’re working on, say, a monorepo for closed-source code that only runs on your own servers, maybe in source code is fine provided there’s no host-level differences that would require a config file.
But for any other circumstance…yeah you need some type of configurability.
Something like
server {
port = 8080
addr = "127.0.0.1"
development = true
}
db {
url = $DB_URL
user = "app"
password = include(".secrets/dbpass.txt")
}1. You hardcode settings in python using a multiline TOML string
2. Users may have multiple configs at the usual config folders
3. The configs override the hardcoded defaults wherever fields are present
4. Configs override each other in order of directories (when we are talking about xdg-directories) and within them in alphabetical order wherever fields are present
This allows you to have good defaults, override some fields at will and add something like 99-debug.toml that you can just rename to 99-debug.toml.invalid if you don't need it anymore. The module also provides an install/edit cli and functions for printing the final resulting config and which configs it read on the way to that final config. At some point I have to publish it.
If you need anything more than TOML because your use case is so crazy, then consider either writing a domain specific language or use a scripting language like lua, python, js, ...
Off the top of my head there's StrictYAML, which likely solves most of the issues, but I'd be interested in a pseudo-language similar to Terraform HCL. It seems config-files-as-scripts are here to stay in the CI world, so why not make config files more scriptable?
Then theres dumb yaml calling smart bash or Makefiles, which has some benefits as well. But I don't see people wanting to split smallish configuration over multiple files. Bash scripts are harder to take in at a glance.
If that was true, it wouldn't have been used as much as it is.
If I ever want something that is just literals and I'm sure I won't need conditionals or variables or fancy stuff, then I'd probably go for scfg[1].
That's a Lot of YAML - https://news.ycombinator.com/item?id=37687060 - Sep 2023 (457 comments)