Hacker News new | past | comments | ask | show | jobs | submit login

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.


The hyphen is associated with the a though. In what's posted, a is a list, not a map - the type of the parent is being declared by that hyphen.


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


FWIW, I think yaml / ansible linters and style checkers typically require indentation.


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


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


Also because the longer the YAML file, the bigger your indentation gets. It gets exponentially worse as you go.


In python that’s been a non-issue, but I’m not sure YAML can reset indentation as python does with functions




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: