Except, we're not done.
YAML has multiple footguns like this, which I have to remember, forever. And anyone who works with YAML. It's unintuitive and confusing, and costs space in my brain that I really should be using for more important things.
Not to mention that if you -don't- know about these ahead of time, debugging them can be confusing.
A type system is marginally more work for decreased cognitive load and eliminating stupid, idiotic bugs that nobody should have to waste their time tracking down.
With IDE integration, the cost is pretty much negligible other than learning the syntax, which, c'mon, is not difficult and we're being paid to do it.
There are even tools like Dhall [0] that auto-generate yaml for us.
enable_feature: yes
Is totally natural. Nobody reads the spec though. If you’re outputting YAML documents with string builders you’re headed for ruin no matter what. You don’t need Dhall, you need yaml.dump which handles the types too. "countries":
- "ca"
- "no"
- "us"From my use case of config files the code that is reading them knows the type anyways. So for a setup like Rust+serde there is no overhead to set this up.
> This problem would be caught immediately anyway if the config is read into static types.
That is true, but it still breaks you out of your flow. You get a confusing error, it probably doesn't tell you the exact line number and you need to look over your changes. If you changed a lot of places in the file it may be easy to miss that adding `no` to a list was the mistake. Because problems like that are easy to understand in retrospect, but if you keep reading "no" as "Norway" it is easy to look straight at this mistake and think it is fine before hunting elsewhere in the file.
I think you are right. It is still unclear if the cognitive overhead when writing the file is worth it, but from my point of view the upsides are much more valuable then you make them appear to be.
The strength of types, in my opinion, is composability. Most config files I've seen have ultimately pulled in input from another source and used that to create their output. Types would allow the configuration to be checked for correctness even in the face of unknowns.
Because I simply don't want to expend the same amount of cognitive load to read config files as I do for code.
Yes, yaml has some minor ambiguities. These are easily solved. To use the example from the article:
There, done. The problem was solved with 2 extra characters and remembering the fact that `no` is special in yaml. Comparing that to the amount of typing I have to do to define a scheme, the syntax of which I have to learn, which I also have to read or remember and keep in mind every time I read the config, I take the 2 extra double-quotes.And, speaking of statically typed languages: This problem would be caught immediately anyway if the config is read into static types.