Live data from Hacker News

Why are we templating YAML?

leebriggs.co.uk

161–170 of 351 posts

Re: Why are we templating YAML?

#161
post #157

Earlier quoted context omitted.

If you think the whitespace is bad, just wait till you see the implicit casting: https://hitchdev.com/strictyaml/why/implicit-typing-removed/

God, I hate programming some times.

Stick with a config format that isn't overengineered and too clever for its own good, like... anything but YAML?

Re: Why are we templating YAML?

#162
post #142
post #88

Earlier quoted context omitted.

Also see `webpack` as a successful example of code-as-configuration in the wild.

Not sure if it was successful when people call it a hell to maintain and newer simpler alternatives like Parcel is gaining popularity.

I still don't know how to get it to do exactly what I want. There is far too much magic involved, and experience has long demonstrated that magic is bad (Webpack confirms that belief).

That being said, the concept of defining a function in, essentially, a config file seems like a step in the right direction. I don't think I'd trust that functionality outside of builds or infra-as-code, though.

Re: Why are we templating YAML?

#163
post #14

Helm reminds me of the 90s level of webtech. I.e. php cgi files mixing html, logic and includes.

I believe people are back to doing that for web stuff. Open up any modern web stuff and it looks like "const widget = foo ". Not making this up! https://reactjs.org/docs/introducing-jsx.html

The difference, at least for Vue single file template components is that it's 3 separate areas in one file:

    -  (Templated HTML)
    -  (JS OR Typescript)
    -  (CSS OR SASS/etc)
Whereas in old PHP files you could mix it in anywhere and the files were a big mess. Including inline SQL into your view templates which is hardly a good separation of concerns. While a Vue component can be separated into separate files, at least as one it all represents one isolated piece of the interface.

https://flaviocopes.com/vue-single-file-components/

Re: Why are we templating YAML?

#164

I know I'm in a minority, but I really dislike YAML... I recently did a lot of Ansible and boy, at the beginning, I was just struggling a lot. Syntactic whitespace kills me. I don't like it in Python either, but for some reason, when I write Python, it's a lot easier. Maybe YAML is just a bit more complex (and Python has better IDE support..?)

I find YAML to be almost unusable. IMO it's just not intuitive. If I get to choose a format for my config files I would only use TOML, it's just better (again IMO).

All these comments amuse me, because I feel the opposite. YAML has always made immediate intuitive sense to me. Meanwhile TOML feels like a terrible hack.

Also, I'm guessing I'm in a tiny minority who loves YAML but hates Python's semantic indentation...

Re: Why are we templating YAML?

#165
post #46

Earlier quoted context omitted.

No comments, constant need to quote every string, inane comma requirements, no multiline string, little typing support.

Many language require strings to be quoted, and calling the comma requirements inane is an opinion, not an objective fact. You're not saying anything about the readability of one versus another, you're just listing gripes you have about JSON.

Parent's points are exactly the reason I'd never consider JSON as config format.

Re: Why are we templating YAML?

#166

His main argument is that you need to template differently for different environments (dev/stage/prod) and cloud regions (us-west/us-east/emea/apac). This is actually a solved problem, and you shouldn't be doing it in your YAML/JSON templates. You should be using an external parameter store to do this, and using a single template for everything. See https://aws.amazon.com/blogs/compute/query-for-the-latest-am... This…

Based on the appearance of Helm, this is probably referring to Kubernetes, which really does have per-environment things that can't be represented in any form other than namespaces. For example, you have an app running (that's a deployment in k8speak). You want network traffic to get to this app, so you set up a load balancer. The load balancer config needs to know the name of your app (or more precisely, a selector…

This is how you do it in AWS CloudFormation:

Parameters: AMI: Type: AWS::SSM::Parameter::Value Default: /aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id

That gives you the latest, fully patched base OS image no matter which of 19 regions you launch it in.

Even hardcoding that in a K/V store is going to get outdated unless you manually update it. Parameters like this are great because you can simply write your code once and never have to update unless you're adding new functionality. All base parameters and external systems (APIs, etc) are parameterized and never need to get updated, except by your SaaS partners that update them for you.

Re: Why are we templating YAML?

#167

His main argument is that you need to template differently for different environments (dev/stage/prod) and cloud regions (us-west/us-east/emea/apac). This is actually a solved problem, and you shouldn't be doing it in your YAML/JSON templates. You should be using an external parameter store to do this, and using a single template for everything. See https://aws.amazon.com/blogs/compute/query-for-the-latest-am... This…

> It's a solved problem For who, exactly?

For anyone using EC2 Parameter Store, a free service in AWS: > Parameters: > AMI: > Type: AWS::SSM::Parameter::Value > Default: /aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id Gives you the latest, fully patched Linux OS in any of 19 regions that you launch it in. Free K/V store that works really well for apps and custom parameters.

Re: Why are we templating YAML?

#168

I think they are missing the real selling point of JSON. It's basically interoperable with JavaScript objects. That means you write it, send it, store it, operate on it, etc. with little or no modification. The author says "converting between the two is trivial" which may be true, but the developer overhead is less trivial. And it will always be JSON in the client - JS doesn't support YAML objects.

When do you ever need to read YAML through vanilla JS? Install YAML/TOML/whatever parser and you're good.

Re: Why are we templating YAML?

#169
post #161
post #157

Earlier quoted context omitted.

God, I hate programming some times.

Stick with a config format that isn't overengineered and too clever for its own good, like... anything but YAML?

That might solve one problem but fighting your tools and occasionally hating the complex giant messes we've engineered is a fact of life for any programmer. I absolutely love programming, just not always the process.

We get better and better tools each year but it still seems unavoidable. We're ultimately building incredibly complex systems with each layer using multiple development approaches, style choices, language choices, degrees of quality/time investment by the creator, etc.

TLDR: you can't help bang your head against the wall in any real-world day-to-day programming

Re: Why are we templating YAML?

#170
post #14

Helm reminds me of the 90s level of webtech. I.e. php cgi files mixing html, logic and includes.

I believe people are back to doing that for web stuff. Open up any modern web stuff and it looks like "const widget = foo ". Not making this up! https://reactjs.org/docs/introducing-jsx.html

So, are you saying those PHP programmers who mix HTML right into code wasn't wrong after all?
Post reply on HN