7 ms·
Yaml is the language nobody needed. All we wanted was a better JSON format that supports comments and doesn’t crash with an extra comma as the end of a list, eg
by AlphaCharlie 1y ago
Yaml is the language nobody needed. All we wanted was a better JSON format that supports comments and doesn’t crash with an extra comma as the end of a list, eg: [1,2,3,]
- watwut 1y agoYes, this.
- karczex 1y agoIn most cases Yaml is bizarre kind of DSL with tricky way of API interaction. For instance - I don't understand why exactly the same Ansible API isn't just python library?
- mdaniel 1y agoFor the same reason any DSL exists: because the programming representation is a lot more verbose than the DSL, due to the computers not currently honoring the "you know what I meant" flag #!/usr/bin/env python3 """A made up example of the line noise""" from ansible import * def main(): hosts = ["localhost"] for h in hosts: run_one_host(h) def run_one_host(inventory_hostname: str): connection = ansible.builtin.ssh(inventory_hostname) print("sniff out the machine's os") host_vars = ansible.builtin.setup(gather_subset="os", connection) if host_vars["distribution"] == "ubuntu": dest = "/etc/apt" else ... dest = "/etc/something else" print("do something awesome") copy_ok = ansible.builtin.copy(src="./some_file", dest=dest, connection) ... That said, I can't readily imagine why you couldn't do exactly what you said because the AnsibleModule[1] contract is JSON over stdin/stdout (and one can write Ansible modules in any programming language[2] - they just default to Python) 1: https://github.com/ansible/ansible/blob/v2.18.4/lib/ansible/module_utils/basic.py#L360 https://github.com/ansible/ansible/blob/v2.18.4/lib/ansible/... 2: https://docs.ansible.com/ansible-core/2.18/dev_guide/developing_program_flow_modules.html#binary-modules https://docs.ansible.com/ansible-core/2.18/dev_guide/develop... and https://github.com/ansible/ansible/blob/v2.18.4/test/integration/targets/binary_modules/library/helloworld.go https://github.com/ansible/ansible/blob/v2.18.4/test/integra...
- vrighter 1y agopython (as much as I personally dislike the language itself) has clean syntax for sets, dicts and arrays. Which are the data structures you use in a playbook. Ansible as python instead of yaml can be made to look very similar to current playbooks. But saner. And easier to script.
- huem0n 1y agoI want multiline strings and references
- marginalia_nu 1y agoHave you considered XML?
- MarkSweep 1y agoOr heck, PLists. They have an XML representation that is fairly similar to what JSON can express. https://en.wikipedia.org/wiki/Property_list https://en.wikipedia.org/wiki/Property_list
- mdaniel 1y agoAs someone who has tried to parse this crazypants as a side-effect of the old 1Password.opvault, please don't. The idea that one has to //key[text()=="firstname"]/following-sibling::string/text() because they're not nested they're siblings. Insanity
- sevensor 1y agoTrailing commas for sure, but I buy the argument that comments would be used to sneak in arbitrary directives and break interoperability. In fact, I’d like to see a less featureful JSON where everything is strings. Trivial parsing, leave interpretation up to the receiver.
- OskarS 1y agoFor a configuration language, comments are absolutely crucial. You want to be able to say "# This option is set because <so-and-so>" to explain why you are configuring it this way to the next person that reads the code (or you, in the future). If the price to pay is that there is some risk some dummy might start parsing the comments as code, so be it. This is not a really a problem in "regular" programming languages, I don't see why it would be in a configuration language.
- mdaniel 1y ago> This is not a really a problem in "regular" programming languages https://go.dev/wiki/Comments#directives https://go.dev/wiki/Comments#directives :-D
- gotimo 1y agoThey said "regular" programming languages
- mmh0000 1y agoI will start by saying, I completely agree with you! But, then, I have to behave like a typical computer nerd and say.. Well ackchuallyyyyyy: > "This is not a really a problem in "regular" programming languages" Browsers do stupid: <!--[if IE 8]> Linux does stupid: #!/bin/bash C/C++ (preprocessor marcos) do stupid: #ifdef https://en.wikipedia.org/wiki/Conditional_comment https://en.wikipedia.org/wiki/Conditional_comment https://en.wikipedia.org/wiki/Comment_(computer_programming) https://en.wikipedia.org/wiki/Comment_(computer_programming)
- 1y ago
- zzlk 1y agoJSON5 is exactly what you're looking for and has somewhat decent adoption. I use it for configuration on one of my projects and I really enjoy it.
- morkalork 1y agoDoes it support float NaNs? Only asking because of Python's quirky non-standard implementation