4 ms·
"There, done." 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 unintuiti
by andrewzah 5y ago
"There, done."
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.
[0]: https://github.com/dhall-lang/dhall-lang https://github.com/dhall-lang/dhall-lang
- TrainedMonkey 5y agoWould most of the footguns be solved by quoting all of the strings? e.g: "countries": - "ca" - "no" - "us"
- kevincox 5y agoYes, but now you are losing a lot of the clean syntax that causes most people to use YAML in the first place. There is a reason that most people don't write YAML like JSON with trailing commas and comments, it is nice to cut most of this noise.
- meowface 5y agoYou can also use a stricter subset of YAML that removes things like the "no" footgun. Plenty of such strict parsers exist across languages. Maybe it's no longer technically YAML at that point, but you get all the nice parts of YAML without having to revamp everything with static typing.
- Spivak 5y agoSo yes it’s a footgun but it makes some sense. Most people wouldn’t really complain about true not being equivalent to “true” or 100 not keeping it “100”. People just aren’t used to yes/no being reserved words. Ruby’s klass is a funny workaround to this. 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.