And I’ll show you YAML
(a continuation of this post)
- interolivary ( @interolivary@beehaw.org ) 49•11 months ago
There’s a special place in hell for the inventor of semantically significant whitespace.
YAML itself is one of the circles of hell. You have to copy-paste YAML from web etc sources with dubious formatting for all eternity, and the editor doesn’t have YAML support. Also you can only use Python
- magic_lobster_party ( @magic_lobster_party@kbin.social ) 14•11 months ago
Indenting copy pasted yaml is always a pain in the butt. Any indentation you give is likely a valid yaml. Especially bad considering indentation has a significant meaning. You have to double check back and forth to ensure nothing bad has sneaked in.
With JSON there are no such discrepancies. It’s likely the editor has figured it out for you already. If it hasn’t it’s easy to prettify the JSON yourself.
- interolivary ( @interolivary@beehaw.org ) 5•11 months ago
Semantic whitespace problems can easily be literally impossible to solve automatically. One of the dumbest fucking ideas anybody ever came up with in computing and its inventor if anyone belongs in YAML Hell. As a fuckup it’s not quite as bad as
null
, but that ain’t exactly a high bar
- synae[he/him] ( @synae@lemmy.sdf.org ) English3•11 months ago
Sounds like a good time to me!
- interolivary ( @interolivary@beehaw.org ) 5•11 months ago
I’m not sure which thought is scarier: that you don’t know what you’re signing up for, or that you do know and you enjoy fixing undecidable formatting fuckups manually
- synae[he/him] ( @synae@lemmy.sdf.org ) English2•11 months ago
There’s a bonus third option: I started writing python professionally in 2007 and nowadays spend 75% of my “hands on keyboard” time working on kubernetes YAML and I am indeed having a good time.
I admit, I hastily misread the tail end of your comment as (e.g.) “A reason YAML is bad because you have to copy-paste from the web and that sucks”; not as you probably meant it “in this special hell, you must deal with copy-pasted nbsp and other trash”. So maybe I did not know exactly what I was signing up for ;)
I don’t deal with anything like that and not entirely sure how it happens to people enough that it is a common complaint. “undecidable formatting fuckups” are a non-issue in my life, I really don’t understand how people encounter such things. Maybe they need to fix their editor/IDE/tools? Skill issue? IDK.
As a tangent- I don’t care what language code is written in, it had better be indented properly (and linted, and follow the project’s codestyle, …). Our juniors learn pretty early that their change requests will be blocked on formatting alone by CI, and a human won’t even bother reviewing the substance of their change if they don’t follow convention. I don’t hear them ever complaining about any of these things, least of all semantic whitespace … and we have a rich culture of bitching about menial/pedantic things ;)
- suy ( @suy@programming.dev ) 49•11 months ago
Norway.
Ups. Sorry, I meant “NO”.
- magic_lobster_party ( @magic_lobster_party@kbin.social ) 34•11 months ago
JSON for serialization all the way. It’s simple and to the point. It does one thing and does it well. There’s little room for annoying surprises. Any JSON can easily be minified and prettified back and forth. If you want it in binary format you can convert it to BSON.
Yaml is too much of a feature creep. It tries to do way too many things at the same time. There are so many traps to fall into if you’re not cautious enough. The same thing can be written in multitudes of ways.
- jjjalljs ( @jjjalljs@ttrpg.network ) 22•11 months ago
Yes, but whoever decided that json can’t have trailing commas has my ire.
{ "a": 1, "b": 2, <-- nope }
There was some other pitfall I can’t remember around missing keys and undefined, too, but I can’t remember it now.
- OmnipotentEntity ( @OmnipotentEntity@beehaw.org ) 12•11 months ago
Change to Haskell formatted commas and the problem goes away :D
{ "a": 1 , "b": 2 , "c": [ 3 , 6 , 9 ] }
- ursakhiin ( @ursakhiin@beehaw.org ) 31•11 months ago
Where is the nearest fire to dump this comment in?
- adambowles ( @adambowles@feddit.uk ) 6•11 months ago
Trailing commas are supported in json5, as well as comments
- colourlessidea ( @colourlessidea@feddit.de ) 15•11 months ago
YAML is pretty good for readability, pretty awful for writability
- synae[he/him] ( @synae@lemmy.sdf.org ) English6•11 months ago
Interesting, I find that the other reasonable options are far less writable than yaml
- MagnoliaMayhem ( @MagnoliaMayhem@programming.dev ) 14•11 months ago
Json. Your move, Joker.
- Terrasque ( @theterrasque@infosec.pub ) 11•11 months ago
puts the json in the yaml parser
Your move, foolish mortal
- derpgon ( @derpgon@programming.dev ) 6•11 months ago
For those uninitiated, every JSON is a valid YAML, since YAML is just a superset of JSON.
- synae[he/him] ( @synae@lemmy.sdf.org ) English13•11 months ago
For serializing? I’d probably just go with json.
For content meant to be written or edited by humans? YAML all day baby
- Andy ( @Andy@programming.dev ) 3•11 months ago
Ever tried NestedText? It’s like basic YAML but everything is a string (types are up to the code that ingests it), and you never ever need to escape a character.
- synae[he/him] ( @synae@lemmy.sdf.org ) English8•11 months ago
I’ve got too many consumers that I don’t control which dictate their input formats. And to be quite honest, “types are up to the code that ingests it” sounds like a huge negative to me.
- Andy ( @Andy@programming.dev ) 3•11 months ago
Ah, well I love that policy (types being in code, not configs). FWIW I sometimes use it as a hand-edited document, with a small type-specifying file, to generate json/yaml/toml for other programs to load.
- nxdefiant ( @nxdefiant@startrek.website ) 11•11 months ago
If you have a choice to start from scratch, TOML is probably the better option.
- urquell ( @urquell@lemm.ee ) 8•11 months ago
So much json here. All wrong, it’s csv
- Artyom ( @Artyom@lemm.ee ) 5•11 months ago
Yaml is a great, human-readible file format. Unless there’s an exclamation point in it, then it is an illegible Eldrich horror.
- JoYo ( @JoYo@lemmy.ml ) English1•11 months ago
I didn’t even know there was a difference.