Live data from Hacker News

Fear and Loathing in YAML

chrisshort.net

41–50 of 107 posts

Re: Fear and Loathing in YAML

#41
> YAML is better than XML but, it sucks compared to something like HTML or Markdown (which I can teach to execs and children alike).

I'm still regularly surprised by Markdown. I have to rely on previews and occasionally still need to check the docs.

My bulleted lists often break and I can never remember the syntax for links.

It's ok to like WYSIWYG even if you're a hacker.

Re: Fear and Loathing in YAML

#42
post #39

Am I the only one who finds YAML much harder to write than JSON or XML? It's not just the fact that I get the syntax for lists and maps confused all the damn time. The worst part is that I'm unable to use the keyboard shortcut for automatically formatting my document! I love that keyboard shortcut! I hate being without it! I'm certain it represents more than half of my key presses in other languages! I type a few cha…

My keyboard shortcut for automatically formatting my documents usually understand the document format or programming language I'm using.

If it doesn't then I'm using the wrong editor.

Re: Fear and Loathing in YAML

#43

I wonder why IDE-enforced markup-schemas haven't caught on. Like a static type system for your markup (i.e. Kubernetes could declare your "types" and your editor could ensure the config fits them). VSCode has something along these lines for JSON - at least on its own settings configuration - but somehow the approach hasn't become prevalent. Are we lacking a standard? Motivation?

IDEA's K8s plugin validates its YAML. It's stricter than K8S itself though.

K8s will accept a cpu value of 0.1, but the plugin marks it as an error, it wants the millicpu version 100m instead.

Re: Fear and Loathing in YAML

#44

I wonder why IDE-enforced markup-schemas haven't caught on. Like a static type system for your markup (i.e. Kubernetes could declare your "types" and your editor could ensure the config fits them). VSCode has something along these lines for JSON - at least on its own settings configuration - but somehow the approach hasn't become prevalent. Are we lacking a standard? Motivation?

I had this exact problem a while ago when trying to have static types for blog entries. I ended up using a strategy where I would write the config in the language that I would eventually use it in (for my blog, my entries became typescript files).

I think perhaps protobufs (specifically text format protos) are a potentially really nice solution, since you get to leverage the protobuf type system. Unfortunately the support for them is a bit lacking.... (afaik, no formal spec - there’s a canonical implementation in C++; no editor support for things like linting and completions).

Re: Fear and Loathing in YAML

#45
I hate this sort of article. Lots of griping about the problems with YAML, but no solutions. What does the author think is better? XML doesn't map to the same data structures as YAML, JSON, and TOML, so it's not really a comparable beast.

The author mentions a desire to be able to teach a data format to people in the way someone can comprehend HTML or Markdown easily. But the formats have different goals.

The goal of HTML and Markdown are to provide a way to encode document formatting in a simple text syntax. There's not one single correct way to format a document intended for presentation to and consumption by humans. Pretty much anything goes, HTML and Markdown just provide some decoration.

But the purpose of YAML (and JSON and TOML) is to provide a way to represent strictly defined data structures for consumption by a computer. The reason YAML is frustrating is because you can't fudge the result; you can't be sloppy or inexact; YAML operates at the boundary between the human and the computer program, and just like any HCI, it's going to be frustrating and error-prone.

Now, would it be possible to come up with a better format than YAML or JSON or TOML that does the same thing? Maybe. But the facts that tools exist to search and manipulate these formats and that we'll probably still be using them in 2030 isn't evidence that they are bad. The fact that yq can exist and is useful is a point in favor of YAML, imo. If simple tools can be written to do useful things with a data format, that makes the format more useful.

Re: Fear and Loathing in YAML

#46
post #6

TOML remains severely underrated, for some reason. It's easy to read, easy to write, trivial to map onto JSON, and refreshingly clear of footguns. There are comments! If you get to pick your format for a configuration language, start by trying to talk yourself out of TOML. You'll probably fail; I'm interested to hear if folks out there have examples of something TOML is bad at, because I didn't come up with any when…

I love TOML for simple data but it starts to have problems with complex data or data in cettain workflows (I can't imagine a Gitlab or Azure Pipelines file in TOML).

However, a benefit to TOML's weakness with complex data is it encourages developers to keep things simple.

Re: Fear and Loathing in YAML

#47

I hate this sort of article. Lots of griping about the problems with YAML, but no solutions. What does the author think is better? XML doesn't map to the same data structures as YAML, JSON, and TOML, so it's not really a comparable beast. The author mentions a desire to be able to teach a data format to people in the way someone can comprehend HTML or Markdown easily. But the formats have different goals. The goal of…

How do you mean? They're all interchangeable.

If you treat XML attributes as @-prefixed variables in the set of json nodes and visa-versa, they're fully compatible.

Re: Fear and Loathing in YAML

#48
post #2

Looking back to the last decade, I cannot remember a single project I worked in that relied on YAML that didn't have at least one incident from its users or developers dealing with the files and messing up. Just some months ago a team I was working with lost almost a day on a misbehaving software module. After serious detective work it all came down to whitespace in a YAML configuration file. I remember being pretty…

Have you considered validating your YAML against a schema? JSON Schema[0] can do the trick, and has decent editor support[1].

It's not a panacea, but it can help avoid those long debugging sessions.

[0]: https://json-schema-everywhere.github.io/yaml

[1]: https://marketplace.visualstudio.com/items?itemName=redhat.v...

Re: Fear and Loathing in YAML

#49
After working with YAML and JSON (and XML and INI and CSV and so on), it seems like a) JSON is equivalent and simpler for basic structures, b) JSON + jq or a language library is better than YAML's complex syntax (like not being able to merge lists[1]), and c) YAML has too many ways to express the same thing. Writing YAML is basically trial and error.

[1] https://stackoverflow.com/q/24090177/96588

Re: Fear and Loathing in YAML

#50
post #49

After working with YAML and JSON (and XML and INI and CSV and so on), it seems like a) JSON is equivalent and simpler for basic structures, b) JSON + jq or a language library is better than YAML's complex syntax (like not being able to merge lists[1]), and c) YAML has too many ways to express the same thing. Writing YAML is basically trial and error. [1] https://stackoverflow.com/q/24090177/96588

Config files should support comments. JSON is being wedged into use cases it simply wasn't designed for.
Post reply on HN