Live data from Hacker News

In Defense of YAML

blog.atomist.com

121–130 of 173 posts

Re: In Defense of YAML

#121
post #115
post #105

Earlier quoted context omitted.

> 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.

> Whatever is the final evaluator gets to define what is required.

Which is completely useless, because it means everyone will do it differently.

> Beyond that, give your users the power to do it their way. Or they will find a way to get it themselves.

Users put value on having a standard set of scaffolding. That's why these standardised config formats have succeeded.

Re: In Defense of YAML

#122
post #119

Related: If you haven’t seen TOML (”Tom's Obvious, Minimal Language”), have a look. It seems pretty nice IMHO. https://github.com/toml-lang/toml

Nested schemas are pretty disgusting in TOML. Granted, there's an argument against having deeply nested schemas in the first place.

Re: In Defense of YAML

#123
At my work we've started rolling out Pulumi as an alternative to YAML hell. The advantages are numerous. It's an integrated programming environment for devops, and engineers can split config and data or unify them as relevant. Sometimes a mix is good!

The TypeScript SDK is extremely thorough and type driven, enabling non-devops engineers to catch more errors before it's run, and it extensively uses asynchrony to build up a graph of resources needed, even if those are across platforms. e.g.: We create a project in Google Cloud, then create a service account, then we create a GKE cluster, then a namespace in the cluster when that's available, then we create roles, ... all of this falls out of simply using their SDK, the resolution of the DAG and awaiting of results is done automatically with some nifty types (almost all inputs can take a promise-like value instead of a POD data type.)

Re: In Defense of YAML

#124
post #50

Earlier quoted context omitted.

Sure thing, but Jinja looks like a garbage fire. Why couldn't they use a regular programming language to create the markup? I mean this is done with HTML and JS all the time.

jinja is great, IMO, and well suited for it's intended purpose. jinja is in wide use in the python community.

Maybe jinja is well-suited to whatever its intended purpose is, but it's not well-suited for programmatically building markup. Using a dynamically typed scripting language to generate the markup at least has the benefit of allowing you to define appropriate semantics via functions ("give me a blob of YAML that represents a Kubernetes service with these parameters").

Sure, you can probably build your own concept of functions on top of Jinja, either by embedding them or building your own paradigm on top of Jinja's template inheritance, but it's a hack either way.

Re: In Defense of YAML

#125
post #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

use-package is a nice declarative way to configure packages in .emacs

Re: In Defense of YAML

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

Okay, you've re-serialized the data structure in a slightly different format. Is there a step 2 I'm not seeing?

Re: In Defense of YAML

#127

Earlier quoted context omitted.

Also "on" and "off", and variations. "y|Y|yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF" https://yaml.org/type/bool.html

"NO" being false is particularly fun: - languages: - en # english - is # icelandic - no # norwegian - ja # japanese - fr # french [{"languages": ["en", "is", false, "ja", "fr"]}]

I feel like 99% of YAML's problems (this being the case in point) would be solved by just treating everything as a string and letting the application interpret it whichever way it sees fit.

Re: In Defense of YAML

#128
If you haven't seen EDN (Extensible Data Notation), it might be worth a look. It was developed by Rich Hickey as a JSON alternative, for use in Clojure. I've found it to be very useful, and not just in Clojure. For example there is an edn crate in Rust.

* https://github.com/edn-format/edn * https://learnxinyminutes.com/docs/edn/ * https://www.compoundtheory.com/clojure-edn-walkthrough/

Re: In Defense of YAML

#129
post #109

Earlier quoted context omitted.

You're taking it too literally/assuming too much. It is super easy. Watch. $ awscli s3 ls Unable to locate credentials. You can configure credentials by running "aws configure". That is stupid. Let's fix it. #!/bin/bash [ -r .awssettings ] && . .awssettings [ -n "$USERN" ] || read -p "What is your username? " USERN if [ ! -n "$PASS" ] ; then read -s -p "Enter your password: " PASS ; echo "" fi [ -n "$REGION" ] || rea…

And how do I put process controls around that? How do I have confidence that someone I'm trying to help over the phone will see the same screens and get the same questions that I do? What do they do if it asks the wrong question? Having simple, predictable, consistent behavior from our tools is far better than trying to guess what the user wanted.

You must live in a different universe from me. In my universe we have been successfully addressing those problems for over 60 years. Also, our tools aren't simple, or predictable, or consistent, which is why our universe created this software called "Docker". It helps, but there's no UI for anything (unless you pay a lot of money) so it's still a pain.

Re: In Defense of YAML

#130
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?

Because their bosses dream up scenarios where customers will be generating config files to be used as templates, etc..., and they're just trying to solve whatever problem was put in front of them and "we'll use YAML", IME. Of course, those scenarios never play out, the thing is bastardized, some new responsibility gets created for some new role where it's their job to handle the template generation on a per customer / per site basis, and on and on we go.
Post reply on HN