this post was submitted on 03 Jan 2025
99 points (95.4% liked)

Programming

17752 readers
1027 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

A 10 minute read covering some YAML edge-cases that you should have in mind when writing complex YAML files

you are viewing a single comment's thread
view the rest of the comments
[โ€“] FizzyOrange 6 points 2 days ago (1 children)

The problem is there aren't really any good alternatives that have as widespread support. I've looked at lots and always found some annoying flaw that JSON or YAML don't have. I mainly want good support in Python, Rust and VSCode.

  • JSON5: This is my ideal alternative but it has surprisingly poor support. No good VSCode extension. There's a Serde crate but it's not very popular.
  • Jsonnet: This has great VSCode support and support for lots of languages including Rust, but for some inexplicable reason they won't let you use it with Serde just to load documents.
  • TOML: This is just not a good format. It's ok for very basic things but any level of nesting and it becomes even worse than YAML.
  • Cue: Only supported language is Go.

There isn't really a perfect option at the moment IMO.

If I'm using Rust I tend to go with RON at the moment. Sometimes I do use YAML but I write it as JSON (since YAML is a superset of JSON) with # comments.

Also never output YAML from your programs. You can always output JSON instead which is better.

[โ€“] [email protected] 3 points 2 days ago* (last edited 2 days ago)

My hierarchy goes something like this:

  • A relatively trivial configuration file? TOML
  • A configuration file that needs a bit of complexity and nesting? YAML
  • Is it getting so complicated and longwinded that you're actually unlikely to touch it by hand anyway? JSON
  • Have we become downright enterprisey? XML