5 ms·
The vast (VAST) majority of the "YAML sucks" examples are solved just by quoting all your weird literals. YAML is definitely annoying at times (list of maps get
by beaviskhan 3y ago
The vast (VAST) majority of the "YAML sucks" examples are solved just by quoting all your weird literals. YAML is definitely annoying at times (list of maps get weird in a hurry, for example, and significant whitespace almost always bites you sooner or later) but these kinds of articles seem disingenuous at best.
- lmm 3y ago> The vast (VAST) majority of the "YAML sucks" examples are solved just by quoting all your weird literals. But none of the examples you see do that, and your tools won't do that. The whole YAML ecosystem nudges you into writing your stuff unquoted, and it works most of the time and breaks just often enough to trip you up in production.
- oblio 3y agoWorse than that, even if you do that... you run into the 11 (I think?) types of YAML strings: https://yaml-multiline.info/ https://yaml-multiline.info/
- Spivak 3y agoPeople shit on YAML then happily use Python that has just as many strings. '', "", f'', f"", b'', b"", """""", "" "", '' '', r'', r"" Then there's docstrings which have special language support, textwrap.dedent, type annotation strings, several different interpolating systems and most people don't even know some of them. YAMLs strings are overblown and are just the result of having a few modifiers. Of all the things to complain about having ways to make chucks of text readable is the weirdest one. Don't even dare look at how many weird strings bash has.
- oblio 3y ago1. I don't use Python happily. 2. I think bash is a bad tool and we just can't get rid of it because it's ubiquitous and people are used to it. Stockholm syndrome. I wish something like Oil shell or Nu shell would take over, ideally a shell which passes objects, not strings.
- Spivak 3y agoI love YSH! But that's an odd take since it's heavily inspired by Python and also has a bunch of string types and 5 different types (i did have to look that up) of string interpolation. Combine that with OSH and you have a language ecosystem that has more weirdness than Bash and Python combined.
- deafpolygon 3y agoI love PowerShell
- bogwog 3y agoThe difference is that Python is a programming language, whereas YAML isn't (allegedly).
- paulddraper 3y agoTo be fair, b'' and b"" are bytes, not text strings. I.e. there is no other literal format.
- kdmccormick 3y agoVery unfair comparison. Python has: * three string syntaxes (regular, formatted, and raw) plus byte arrays. * single vs double quotes, which are insignificant, other than that you don't need to escape the containing literal quote type. * inline vs multiline. These all compose in a predictable way. If you want to be a jerk, you can multiply 4 * 2 * 2 and say "ZOMG 16 string types!!", but that's about as fair as saying that having positive/negative, octal/hex/dec, int/float, and standard/scientific means that a language has 24 numerical types.
- Spivak 3y agoYou also forgot implicitly concatenated strings. "hello" "world" blah = ( "line" "line" ) They are actually really useful when you want multi-line formatted strings without indentation and had to be made official when people wanted to take them away. > If you want to be a jerk, you can multiply 4 * 2 * 2 and say "ZOMG 16 string types!!" And now you understand how they calculated the number of string types in YAML.
- oblio 3y agohttps://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines/21699210#21699210 https://stackoverflow.com/questions/3790454/how-do-i-break-a...
- paulddraper 3y agoRight? It's 30% of the reason people write YAML instead of JSON.