Live data from Hacker News

In Defense of YAML

blog.atomist.com

111–120 of 173 posts

Re: In Defense of YAML

#111
post #72

I'm usally confronted at YAML when I setup gameservers of some indie games (I'm looking at you Empyrion) and I find it extremely painful to handle. When you have sevral configuration files where you have to change/tweak data I always end up pulling my hairs why stuff isn't working because of an extra space lying anywhere in the file. Please don't use YAML for anything that has to be edited by a human INI, XML, JSON a…

It's weird how languages like YAML, XML and JSON are very much designed for communication between machines, but are still the default choice for human input. Actual programming languages - designed for use by people - are rarely considered for high level configuration. I have actually seen something similar to this happen: 1. We just need a few configuration options. Let's add an XML configuration file. 2. Keeping al…

>It's weird how languages like YAML, XML and JSON are very much designed for communication between machines, but are still the default choice for human input. Actual programming languages - designed for use by people - are rarely considered for high level configuration.

What are you talking about? YAML, XML (particularly HTML) and JSON were always intended to be written by and understood by human beings, no less so than any "programming language." All of these were designed to be "used by people" and machines.

>Actual programming languages - designed for use by people - are rarely considered for high level configuration.

And the rest of your comment illustrates why. What you have when you use a programming language for "high level configuration" isn't configuration. Configuration should describe constant state, not operate on or transform mutable state. What you have, then, is just more application layer, on top of your application.

Which you don't have with JSON. Or INI. And you do still kind of have with YAML, and definitely can with XML, but that's why a lot of people don't like YAML or XML when it gets too complex.

What it looks like your example shows is dumping unnecessary complexity into configuration in order to maintain "simplicity" in the application. You would have the exact same problem using a high level programming language, it would just be potentially infinitely worse with the explosion of complexity and feature creep that comes with it.

Re: In Defense of YAML

#112
post #19

Earlier quoted context omitted.

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.

But...they will be able to write DSLs in it. Just create functions with the same name as the head atom of the top level lists, then run the config file as a program. Or write macros matching the syntax of your format to generate code. I mean, maybe there is something about your format that makes these specific approachs inconvenient. But once you give a Lisper a bunch of S-expressions, you just opened the door for th…

I don't think many non lispers realize that you can pass the same structure to different parts of your program for different manipulations or executions. Truly, the code as data mantra is just too removed from most languages. It is too easy to think eval is something that can just take in a string, at best. Completely missing that you can literally change how your code is evaluated.

Re: In Defense of YAML

#113
post #95

The configuration method for the Gunicorn server ( http://docs.gunicorn.org/en/stable/configure.html#configurat... ) would be a great example to follow. Configuration files are just Python modules. You can specify the number of workers and set log file locations with the following: from multiprocessing import cpu_count def max_workers(): return cpu_count() * 2 + 1 workers = max_workers() errorlog = "/var/www/lcfs/log…

You should see how people configure their emacs setups. :D

Re: In Defense of YAML

#114
post #95

The configuration method for the Gunicorn server ( http://docs.gunicorn.org/en/stable/configure.html#configurat... ) would be a great example to follow. Configuration files are just Python modules. You can specify the number of workers and set log file locations with the following: from multiprocessing import cpu_count def max_workers(): return cpu_count() * 2 + 1 workers = max_workers() errorlog = "/var/www/lcfs/log…

Gunicorn probably got this idea from Django, which probably got the idea from Lisp (see also, emacs). :-)

Re: In Defense of YAML

#115
post #105
post #76

Alternatively, if you're programming and you want a structured data format, use S-expressions! They are basically tailor-made for exactly this problem. (gitlab:assets:compile #%dedicate-no-docs-pull-cache-job (image "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.5.3-git-2.18-chrome-71.0-node-8.x-yarn-1.12-graphicsmagick-1.3.29-docker-18.06.1") (dependencies setup-test-env) (services (docker stable-dind)) (var…

> And that’s just a first cut; it could be made much nicer. This is exactly the problem with S-expressions. No-one is willing to define what "good enough" looks like and create a fixed, reusable standard for how you represent these things. Instead everyone hand-rolls their own, subtly incompatible variant.

Whatever is the final evaluator gets to define what is required. Beyond that, give your users the power to do it their way. Or they will find a way to get it themselves.

Re: In Defense of YAML

#116
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…

> This is programming masquerading as configuration

On a slight side-note this is something that's been bothering me with markdown and other markup languages.

They're very good for short comments but when you're writing a blog post, or god forbid an article series or a book, sometimes having access to a programming language is fantastic.

It's why I like a markup like Pollen use. Also X-expressions fits very well to model a document.

Re: In Defense of YAML

#117
On the flip-side, if you were to embrace using YAML for programming (i.e. by creating a programming "language" by treating certain YAML constructs specially), you'd likely end up with a homoiconic Lispy language (albeit a very weird one), just using YAML instead of S-expressions (maybe call 'em Y-expressions?).

Re: In Defense of YAML

#118
post #21

Earlier quoted context omitted.

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 lear…

Would you expect all sysadmins to become programmers?

Yes.

And back in the day sysadmins wrote programs like tcp_wrappers, postfix, sendmail, etc. It was definitely common and encouraged if not expected.

The idea that system admins should be able to get away with never professionally stepping up to doing programming is a late-90s/early-00s aberration that was generated by the need to scale up during the dot com boom before good automation practices existed. And it is not a good thing and it stunts intellectual growth. Devops is in some sense back-to-the-future by tearing down an artificial wall that never should have been made in the first place.

Re: In Defense of YAML

#120

Earlier quoted context omitted.

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

You can make Tcl as non-Turing complete as you wish. Stripped of most or all builtin commands, it becomes a flexible configuration language. You can add back power in small controlled doses as it becomes necessary. You can also make it more palatable to the cool kids by adding infix assignment and expression evaluation with a few simple helper procs.

This was a big part of what motivated me to create OTPCL [1]; using full-blown Erlang or Elixir for configuration files feels dangerous and heavy-handed, and I want to be able to readily define DSLs for configuration files instead to offer better control/safety/ergonomics. Plus, I happen to like Tcl ;)

Imagine being able to go from a foo.app like this:

    {application,otpcl,
                 [{description,"Open Telecom Platform Command Language"},
                  {vsn,"0.1.0"},
                  {modules,[otpcl,otpcl_env,otpcl_eval,otpcl_init,otpcl_parse,
                            otpcl_shell,otpcl_stdlib,otpcl_stdmeta]},
                  {registered,[]},
                  {applications,[kernel,stdlib]},
                  {licenses,["ISC"]},
                  {links,[{"Bitbucket","https://bitbucket.org/YellowApple/otpcl"},
                          {"GitHub","https://github.com/YellowApple/otpcl"}]}]}.
to something more like a foo.app.otpcl:

    application otpcl {
        description "Open Telecom Platform Command Language"
        vsn 0.1.0
        modules otpcl otpcl_env otpcl_eval otpcl_init otpcl_parse \
                otpcl_shell otpcl_stdlib otpcl_stdmeta
        registered
        applications kernel stdlib
        licenses ISC
        links {
            Bitbucket "https://bitbucket.org/YellowApple/otpcl"
            GitHub "https://github.com/YellowApple/otpcl"
        }
    }
I dunno about you, but I like the latter a lot better :) It ain't a 1:1 representation, but it'd be straightforward to define each of those parameters as commands that emit the corresponding Erlang forms that make up an actual app spec.

While OTPCL's by no means ready for primetime yet, I'm hoping it'll eventually be good enough to fill that niche in the Erlang/OTP ecosystem the same way Tcl was meant to fill that niche for software in general.

[1]: https://otpcl.github.io / https://github.com/otpcl/otpcl

Post reply on HN