Live data from Hacker News

Why are we templating YAML?

leebriggs.co.uk

31–40 of 351 posts

Re: Why are we templating YAML?

#31
post #12

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.

But the simpler format of JSON should be easier to write and read.

See sibling comment.

Re: Why are we templating YAML?

#32
As others in this thread have said: I ask this question all the time, except s/templating/using/.

YAML is insanely over complicated; it's as bad or worse than XML for config files, and it doesn't even have the nice streaming mode. Not to mention that it's a bit of a security nightmare (seriously, who put pointers into the YAML spec?).

And, on a more subjective note, YAML is just confusing: between all the significant whitespace and the random single character symbols that no one ever remembers what they do, I never get a YAML document right on the first try.

Templating it really does add a whole new level of headache too.

Re: Why are we templating YAML?

#33

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

Tools keep using it even where it's the wrong tool for the job, so someone must like it, surely?

I'm sure it will be just like XML where it's the trendy thing for a while in the early days, then everyone stops and hates it for a while. Except XML at least has a handful of applications where it's the right tool for the job (it has a nice streaming mode), YAML doesn't even have that.

Re: Why are we templating YAML?

#34
post #10

Earlier quoted context omitted.

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.

A misplaced comma is also not a problem in an editor with syntax highlighting, but between the two, indentation could take longer to fix.

Re: Why are we templating YAML?

#35
post #19

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

The best thing that ever happened to Cloud Formation was the new YAML syntax. Writing YAML is easy with a good editor like VSCode. Install the YAML code outline extension for sugar; works great for OpenAPI specs. YAML flow style offers some good options for keeping the file compact.

I'm all for good editor support, but you shouldn't need it to write a simple document. Complicated editors should be supporting tools at best, because you won't always be in a position to use one. The things we write should be simple enough to be written and understood by hand with minimal mistakes (then we can make it even easier in some cases using nice editors and tooling).

Re: Why are we templating YAML?

#37
post #34

Earlier quoted context omitted.

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.

A misplaced comma is also not a problem in an editor with syntax highlighting, but between the two, indentation could take longer to fix.

Syntax highlighting doesn't count commas. The problem is JSON doesn't allow trailing commas, so adding or reordering frequently results in a difficult to diagnose error.

Re: Why are we templating YAML?

#38
post #8

Earlier quoted context omitted.

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…

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 think its because python has very strict and very simple indentation rules (a nested block must be indented, and the file requires consistent indentation. Is there anything else?)

YAML gives you options, or varies necessity somewhat arbitrarily on the structures, which is (marginally) good for reading, but a lot of headache in writing

Re: Why are we templating YAML?

#39

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

I really like TOML as a compromise between "looks pretty" and "parses well".

That being said, I find it funny that the author is crying afoul, saying that YAML isn't as well suited to be templated as JSON is, when XML had schemas sorted out ages ago.

People ran away from XML, saying it was this verbose, ugly, bandwidth hungry (back when we were sending XML over AJAX) behemoth (which it totally is)... but I think when your usecase is complicated enough to worry about templating, you should take a hard look at XML and ask whether it might suit your better.

Re: Why are we templating YAML?

#40
post #12

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.

But the simpler format of JSON should be easier to write and read.

No comments, constant need to quote every string, inane comma requirements, no multiline string, little typing support.
Post reply on HN