Live data from Hacker News

Why are we templating YAML?

leebriggs.co.uk

21–30 of 351 posts

Re: Why are we templating YAML?

#21
post #16
post #8

Earlier quoted context omitted.

White space matters with Python but I rarely run into issues with indentation in Python. But YAML on the other hand, I have nothing but nightmares.

I have the same experience. I just think think it is possible to design easy-to-write indentation-sensitive formats but YAML is not. For example is always baffles me that a: - b - c has a list inside an object but the list is not further indented. There's in fact a hierarchy relationship but absolutely no indentation.

You can indent it though, but the hyphen already means a list item.

That is a preferred syntax for many that are used to YAML though.

Re: Why are we templating YAML?

#22
post #16
post #8

Earlier quoted context omitted.

White space matters with Python but I rarely run into issues with indentation in Python. But YAML on the other hand, I have nothing but nightmares.

I have the same experience. I just think think it is possible to design easy-to-write indentation-sensitive formats but YAML is not. For example is always baffles me that a: - b - c has a list inside an object but the list is not further indented. There's in fact a hierarchy relationship but absolutely no indentation.

That's at your option, though. It's perfectly valid yaml to indent the list as many spaces as you want.

Re: Why are we templating YAML?

#23
I didn't see this mentioned anywhere else, so another alternative (that I've seen and really like conceptually, but haven't used so far) to all this wildness with YAML and JSON -> https://github.com/dhall-lang/dhall-lang, and for kubernetes specifically -> https://github.com/dhall-lang/dhall-kubernetes

Re: Why are we templating YAML?

#24
Helm charts are great, and accomplishes the task, but things get really weird and complex if you're not careful. Oh man, the indentation and _helper.tpl nightmares. It's not obvious at all. And there's still a lot of repetition for each chart; writing a deployment or whatever is so verbose in K8s.

On the other hand, Ansible uses yaml and there it works great. I feel like Ansible uses yaml in a way that's easier to understand and the way it was meant to be written. With Ansible, you're writing configuration, not templates of configuration. I don't think a layer on top of Ansible like Helm is for K8s wouldn't make sense.

Re: Why are we templating YAML?

#25
Who knows.

It makes me throw up a little in my mouth every time I see hundreds of lines of YAML to configure something like Traefik with Kubernetes. The worst is when people say they prefer that because "I don't have to write a config file for my backend". That's true but instead now you have extremely verbose configuration mixed in with other verbose configuration.

But in YAML's defense I think it's more of a problem with the tools that use it more so than YAML itself. Ansible is a great example of how amazing YAML can be to manage complex configuration in a concise way.

Re: Why are we templating YAML?

#26

The real question is why are we using yaml at all?

Baffles me. I don't like any language or file format where whitespace matters. Even Haskell bothers me in this regard. To me white space shouldn't add cognitive load. I want to look at the symbols not the formatting of the antisymbols to understand what is going on. Write JSON and use your editor tools to format it with nice indentation, and you are sweet! That said Yaml makes an excellent format for reading, but not…

I never quite understood this attitude. Not treating whitespace as meaningful means it's necessary to have a longer, syntactically noisier file.

That's fine if you're primarily concerned with computers exchanging data (JSON) but where readability and writability matters, extra syntactic weight is a headache.

I can't imagine writing JSON by hand but I write plenty of YAML by hand every day without issues.

Re: Why are we templating YAML?

#27
I know I'm in a minority, but I really dislike YAML... I recently did a lot of Ansible and boy, at the beginning, I was just struggling a lot. Syntactic whitespace kills me.

I don't like it in Python either, but for some reason, when I write Python, it's a lot easier. Maybe YAML is just a bit more complex (and Python has better IDE support..?)

Re: Why are we templating YAML?

#28
post #21
post #16

Earlier quoted context omitted.

I have the same experience. I just think think it is possible to design easy-to-write indentation-sensitive formats but YAML is not. For example is always baffles me that a: - b - c has a list inside an object but the list is not further indented. There's in fact a hierarchy relationship but absolutely no indentation.

You can indent it though, but the hyphen already means a list item. That is a preferred syntax for many that are used to YAML though.

That's kind of my point. Indentation is optional, so many don't indent, making the resulting document harder to understand.

Re: Why are we templating YAML?

#29

I know I'm in a minority, but I really dislike YAML... I recently did a lot of Ansible and boy, at the beginning, I was just struggling a lot. Syntactic whitespace kills me. I don't like it in Python either, but for some reason, when I write Python, it's a lot easier. Maybe YAML is just a bit more complex (and Python has better IDE support..?)

>> I really dislike YAML

I wasn’t aware anyone liked it

Re: Why are we templating YAML?

#30
post #10

Earlier quoted context omitted.

It's a lot easier for end-users to read and write by hand. If that is not a requirement, a simpler machine-friendly format is likely better.

Writing YAML is not easy for end-users. The indentation--especially in large files--is really difficult to keep track of, and some really basic stuff like when to quote strings is not consistent at all.

Nope, indentation is not a problem with indentation guides. A misplaced comma in a JSON file however kills it, gets me every time I have to write it by hand.

Also, it is true YAML has too many features, though I find they are typically ignored or disabled.

Post reply on HN