Live data from Hacker News

In Defense of YAML

blog.atomist.com

21–30 of 173 posts

Re: In Defense of YAML

#21
post #8

You want to see a real abuse of YAML? Take a look at SaltStack's Jinja rendered YAML. I just grabbed a random forumla as an example: https://github.com/saltstack-formulas/openssh-formula/blob/m...

I don't understand why people use a markup language when they need a programming language. I mean, sure, you can convert one into the other syntax-wise, both form trees, but what do you gain?

From what I've experienced, it's mostly tools that target either sysadmins or sysadmins-turned-pseudo-devops, and those tools pretend that anything can be done with 'just configuration' as a marketing point. Programming is for programmers, you see.

It's easy for someone who never {wanted to, learned to} program to accept yet another configuration format (with all options specified up front) and then accidentally learn (bastardized) programming concepts. It'd take much more effort to turn them into a 'real' programmer, learning a language from scratch, practicing that, and only then introducing some tool in the form of a library.

Re: In Defense of YAML

#23
post #19
post #2

> Note the script block containing a list of shell scripts. Does this look like data? Code is Data! Lisp-it or Quit!

One of these days, I want to come up with a non Turing complete s-expression based config format (basically something like a Lispy JSON) and post it here just to watch Lispers rage at not being able to write DSLs in it.

Kicad uses non-turing-complete S-expressions as a file format: https://github.com/KiCad/Connectors.pretty/blob/master/bnc-c...

Re: In Defense of YAML

#24
OK, I totally get the argument that YAML is for data and not programming. But I'm not sure the line between them is always clear.

For example: I used to use YAML to define field mappings between external data and internal models in a Rails application.

like:

  - src: fieldA
    dest: field_a
    filter: name_of_some_filter_function

Is this programming? Data? Really it's configuration for an import library, but I find the line blurry.

Re: In Defense of YAML

#25
post #15

You can actually use Python as a configuration file pretty well, if you need more complicated logic and macros. Otherwise, sticking to a toml or ini file is my preference.

Are you gonna embed a Python interpreter into your C# programs though? Better to use something like dhall that's at least open to being loaded from multiple languages.

Re: In Defense of YAML

#26
post #3

> This is not structured data. This is programming masquerading as configuration I find myself expressing this same opinion to people on a frequent basis. See ansible for another big example. Ansible has a try/catch equivalent in yaml [0]! Unfortunately, YAML is more or less a lowest common denominator for these sorts of interactions - being usable from any language is a really big boon. Would love to see the world a…

What about https://dhall-lang.org/ ?

Also https://jsonnet.org/ .

Both of them are basically BCL/GCL but with some semantic/scoping horrors removed.

Re: In Defense of YAML

#27
post #15

You can actually use Python as a configuration file pretty well, if you need more complicated logic and macros. Otherwise, sticking to a toml or ini file is my preference.

INI is the best config format imo since you can't do anything more complicated than assigning a value to a key in a namespace. The Dist::Zilla config file was a real eye-opener at what you can achieve with this kind of siimplicity.

Re: In Defense of YAML

#28

Earlier quoted context omitted.

Yeah, they probably should have had special syntax for booleans.

The problem is that they have too much special syntax for booleans.

I meant that they should have special syntax that isn't ambiguous (to a human reader). Just treating bare words as either strings or booleans depending on their value is what makes it confusing.

Re: In Defense of YAML

#30
post #12

Something I've never liked about YAML, and I've not found a way around, is that you can't know if you have the entire file because there isn't an end marker. If someone cut'n'pastes a block of YAML you don't know if they missed a bit off the end by mistake (unless you know the schema). That makes it harder to debug problems with YAML config.

From the YAML spec[1]:

> Three dots ( “...”) indicate the end of a document without starting a new one, for use in communication channels

[1] https://yaml.org/spec/1.2/spec.html#id2760395

Post reply on HN