r/sysadmin • • May 19 '20

Microsoft 📢 Windows Package Manager | winget.exe

[deleted] — view deleted post

384 Upvotes

126 comments sorted by

View all comments

Show parent comment

1

u/Atemu12 May 19 '20

Oooh YAML-based.

Not as cool as a language specifically made for package declaration like Nix but the next best thing IMO.

4

u/ErikTheEngineer May 19 '20

Oooh YAML-based.

Off topic, why does everyone love YAML so much? Or any file format where whitespace matters for that matter? I get it, XML is super-verbose, JSON isn't intuitive for non programmers...but YAML?? I don't get it...

5

u/[deleted] May 20 '20

You kind of listed the reasons there...

What else is compelling you think people are missing?

4

u/BadgersInSpace May 20 '20

Because all valid YAML is convertible to valid JSON and vice versa. It's more natural and faster (for me at least) to write something in YAML than in JSON and the whitespace makes it easy to read and makes it look consistent across editors or applications vs having to pretty-print JSON output because 9 times out of 10 it's going to have the whitespace stripped.

I interact with it on a day to day basis for configuration files, and one of the most useful things is the ability to create multi-line strings with |. Trying to do that in JSON requires manual escaping of the newlines, quotes, etc. which would be a nightmare for passing in the text of a Python script, for example, to a content parameter of a Puppet file resource.

YAML is for humans to write something to tell the machine something, where JSON is machine-speak for talking to other machines that is intelligible to humans and can be spoken relatively easily if a human needs to initiate a machine is my interpretation.

Extending that comparison, XML is speaking proper Formal English constantly, which gives you the exact unambiguous specifics... in three times as long as it would have taken to say it in vernacular.

tl;dr less of a pain in the ass to write something in YAML over JSON, and fuck XML

3

u/ExistingObligation May 20 '20

Small correction, valid YAML is not easily convertible to JSON without losing information (namely comments) but the reverse is true, i.e. JSON is a subset of YAML.

1

u/jantari May 20 '20

YAML is easy as fuck and very powerful.

Constructs like verbatim inline text are only possible because of whitespace rules:

verbatim-text: |
  I can \have\ all matter of crazy
    shit here
  and everything including  double  spaces

  Or new
  L
  INES

  \\{ will be preserved perfectly