News for hackers. Stuff that matters.
Re:YAML: Probably not so great after all by jchw on Sunday August 18, 2019 @06:12PM (#20733275)
The issue is, I think most people (myself included) enter YAML into their lives as basically a JSON alternative with lighter syntax. Without really realizing, or perhaps without internalizing, the rather ridiculous number of different ways to represent the same thing, the painful subtle syntax differences that lead to entirely different representations, the sometimes difficult to believe number of features that the language has that are seldom used..

It's not just alternate skin for JSON, and yet that's what most people use it for. Some users also want things like map keys that aren't strings, which is actually pretty useful.

I recall there being CoffeeScript Object Notation as well... perhaps that would've been better for many use cases, all things said.

Re:YAML: Probably not so great after all by norcalli on Sunday August 18, 2019 @09:05PM (#20734084)
I've never understood this. JSON is really not that difficult to work with manually. I tend to write my config files as JSON for utilities I write. What is it with peoples' innate aversion to braces?
Re:YAML: Probably not so great after all by zzo38computer on Sunday August 18, 2019 @09:12PM (#20734115)
I don't aversion to braces. Rather, my issues with JSON is that it doesn't have comments and that you cannot use a optional trailing comma.
Re:YAML: Probably not so great after all by EamonnMR on Sunday August 18, 2019 @09:24PM (#20734165)
Having spent a nontrivial amount of my life hand editing large JSON files now, I have to agree here. Lack of comments and trailing commas are a real QOL issue.
Re:YAML: Probably not so great after all by thiht on Monday August 19, 2019 @09:30AM (#20737549)
Also no multiline strings. Using \n or string arrays is painful.

I don't get why TOML is so underrated, it's barely mentioned in the HN discussion

Re:YAML: Probably not so great after all by gpvos on Monday August 19, 2019 @11:25AM (#20738562)
Thanks for mentioning it; I hadn't encountered it yet and it seems like a very sane config file format. There's several mentions in this discussion actually, nearly all positive.
Re:YAML: Probably not so great after all by JoBrad on Sunday August 18, 2019 @10:17PM (#20734381)
And the required double quotes around strings. YAML’s string handling is a lot easier to deal with.
Re:YAML: Probably not so great after all by zzo38computer on Monday August 19, 2019 @11:33AM (#20738648)
I think it is good to require quotation marks for strings, at least for values (although I could live with it if quotation marks for strings are allowed even if not required, since then, if you do not like the feature of not having quotation marks for strings, you can just not use that feature).

Maybe it would be sense if quotation marks were not required for keys with only a restricted character set which are not an empty string, though.

Re:YAML: Probably not so great after all by JoBrad on Wednesday August 21, 2019 @10:34AM (#20757590)
No quotes around keys would be sufficient, honestly. I use YAML a lot for API documentation, and there are still some cases where wrapping your values in quotes is necessary. But requiring it for keys becomes very annoying.
Re:YAML: Probably not so great after all by jtdev on Sunday August 18, 2019 @10:52PM (#20734512)
It’s also a lot less obvious. What’s so difficult about wrapping a string in double quotes?
Re:YAML: Probably not so great after all by h1d on Sunday August 18, 2019 @11:02PM (#20734560)
It gets annoying when you have to do what seems unnecessary.
Re:YAML: Probably not so great after all by Griffinsauce on Monday August 19, 2019 @02:39AM (#20735435)
It's not really unnecessary when someone can write an entire article on how unfathomable the output is without them.
Re:YAML: Probably not so great after all by acdha on Monday August 19, 2019 @06:29AM (#20736533)
It’s easier until you hit one of the cases where a particular value is interpreted as a different type, possibly in a very confusing context. I’ve seen that bite enough people that I end up quoting strings to avoid confusion.
Re:YAML: Probably not so great after all by heavenlyblue on Monday August 19, 2019 @09:32AM (#20737561)
It’s also extremely hard to learn as a beginner.

“Hey, I deleted a character in a string and now I am getting this weird schema validation exception”.

Re:YAML: Probably not so great after all by acdha on Monday August 19, 2019 @10:04AM (#20737818)
Or “Why did it break when I changed the version from 3.7 to 3.7.1?”
Re:YAML: Probably not so great after all by theknarf on Monday August 19, 2019 @06:41AM (#20736597)
Re:YAML: Probably not so great after all by zzo38computer on Sunday August 25, 2019 @12:18PM (#20793762)
JSON5 looks like good, actually. It has all of the added features that it should have.

They don't mention mismatched surrogates and otherwise invalid Unicode characters, but they should perhaps be implementation-dependent, like duplicate keys are. (It can either allow them or report an error.) There is also the possibility that some implementations may wish to disallow "\x00" or "\u0000" too, I think.

The thing I disagree is the part about white space. U+FEFF should be allowed only at the beginning of the document (optionally), and other than that only ASCII white space should be allowed. Unquoted keys also should be limited to ASCII characters.

Other than that, I think it is good.

Re:YAML: Probably not so great after all by nine_k on Sunday August 18, 2019 @09:30PM (#20734192)
JSON is serviceable as an intermediate format, machine-generated and machine-consumed.

It is outright bad as a human-operated format. It explicitly lacks comments, it does not allow trailing commas, it lacks namespaces, to name a few pain points.

YAML is much more human-friendly, with all its problems.

Re:YAML: Probably not so great after all by jtdev on Sunday August 18, 2019 @10:56PM (#20734535)
I often hear the “comments aren’t supported” argument against JSON, but as a daily consumer, creator, and maintainer of JSON, I honestly can’t recall ever _really_ needing comments in JSON. It tends to be somewhat self documenting in my experience.
Re:YAML: Probably not so great after all by h1d on Sunday August 18, 2019 @11:05PM (#20734567)
A config file without comments can mean serious annoyance.

If JSON was developed more recently on places like GitHub, it would never have ended up like that with that many deficiencies.

Re:YAML: Probably not so great after all by nine_k on Sunday August 18, 2019 @11:06PM (#20734571)
When maintaining a JSON file, did you ever happen to wonder why a particular value is what it is?

This is where comments belong.

Re:YAML: Probably not so great after all by CriticalCathed on Monday August 19, 2019 @12:10AM (#20734826)
If it's that important and complex, have an accompanying README that lists line numbers and comments.
Re:YAML: Probably not so great after all by js8 on Monday August 19, 2019 @01:59AM (#20735245)
Good idea! And then put a comment into the configuration file that refers to where the documentation is.. ah, f__k!
Re:YAML: Probably not so great after all by meddlepal on Monday August 19, 2019 @12:29AM (#20734905)
Lesson to learn: Nobody reads the docs.
Re:YAML: Probably not so great after all by CriticalCathed on Monday August 19, 2019 @03:14AM (#20735593)
This is such a dumb aphorism. I read and create docs every single day.

If the comments are so critical that it is a problem, then an accompanying file with those comments would be used. Otherwise, it's just a bunch of crocodile tears.

Re:YAML: Probably not so great after all by voidfunc on Monday August 19, 2019 @12:27AM (#20734893)
The lack of comments is the real problem. When you need to explain why a particular parameter in the config file is set a certain way JSON becomes a real problem.
Re:YAML: Probably not so great after all by ivalm on Monday August 19, 2019 @04:06PM (#20741311)
Comments, comments, comments.

Seriously, our batch jobs for better or worse have configs with a bunch of parameters that are passed around as json, and while most variable names are intuitive and there is documentation on the wiki, and most often the config can be autogenerated by other tools it would still be better if when I manually open it in the config itself I would easily see the difference between n_run_threads vs n_reg_threads, etc...

Re:YAML: Probably not so great after all by brokensegue on Sunday August 18, 2019 @10:11PM (#20734367)
json's lack of int types is what ruins it for me
Re:YAML: Probably not so great after all by crdoconnor on Sunday August 18, 2019 @06:55PM (#20733477)
JSON alternative with lighter syntax and comments is basically what I tried to make StrictYAML.

I made it largely because I saw a disconnect with what YAML was, and what people - including me - thought it was (which is what it should be).

Don't agree with non-string map keys though... they're a complication I never saw a use for.

Re:YAML: Probably not so great after all by zenexer on Sunday August 18, 2019 @07:57PM (#20733745)
They’re fairly useful in applications that use numeric IDs. For example, if I’m using SQL, and I have a table with an AUTOINCREMENT primary key, I’m going to have a lot of numeric IDs. If I want to reference these in a config file of some kind, I don’t want to have to read them as strings and handle the parsing on my end.

Even if you’re of the opinion that IDs shouldn’t be numeric, there are a lot of cases where you’re stuck with integers—on Linux, user IDs, group IDs, and inodes are just a few examples.

Re:YAML: Probably not so great after all by crdoconnor on Sunday August 18, 2019 @08:12PM (#20733821)
Ah I see, yes that makes perfect sense. I've used integer keys too. Sorry, I thought by non-string you meant non-scalar - i.e. the idea of using lists as keys (allowed in YAML).
Re:YAML: Probably not so great after all by zbentley on Sunday August 18, 2019 @09:09PM (#20734100)
I think they did mean nonscalar keys. Say I have a compoubd primary key in a database, over 3 columns. In YAML, representing that key as an array of the three columns' values (or a map from column name to value) makes sense, and so does using that as a key in other maps.
Re:YAML: Probably not so great after all by DonHopkins on Monday August 19, 2019 @01:54AM (#20735231)
I was suspicious of YAML from day one, when they announced "Yet Another Markup Language (YAML) 1.0", because it obviously WASN'T a markup language. Who did they think they were fooling?

https://yaml.org/spec/history/2001-08-01.html

XML and HTML are markup languages. JSON and YAML are not markup languages. So when they finally realized their mistake, they had to retroactively do an about-face and rename it "YAML Ain’t Markup Language". That didn't inspire my confidence or look to me like they did their research and learned the lessons (and definitions) of other previous markup and non-markup languages, to avoid repeating old mistakes.

If YAML is defined by what it Ain't, instead of what it Is, then why is it so specifically obsessed with not being a Markup Language, when there are so many other more terrible kinds of languages it could focus on not being, like YATL Ain't Templating Language or YAPL Ain't Programming Language?

https://en.wikipedia.org/wiki/YAML#History_and_name

>YAML (/ˈjæməl/, rhymes with camel) was first proposed by Clark Evans in 2001, who designed it together with Ingy döt Net and Oren Ben-Kiki. Originally YAML was said to mean Yet Another Markup Language, referencing its purpose as a markup language with the yet another construct, but it was then repurposed as YAML Ain't Markup Language, a recursive acronym, to distinguish its purpose as data-oriented, rather than document markup.

https://en.wikipedia.org/wiki/Markup_language

>In computer text processing, a markup language is a system for annotating a document in a way that is syntactically distinguishable from the text. The idea and terminology evolved from the "marking up" of paper manuscripts (i.e., the revision instructions by editors), which is traditionally written with a red or blue pencil on authors' manuscripts. In digital media, this "blue pencil instruction text" was replaced by tags, which indicate what the parts of the document are, rather than details of how they might be shown on some display. This lets authors avoid formatting every instance of the same kind of thing redundantly (and possibly inconsistently). It also avoids the specification of fonts and dimensions which may not apply to many users (such as those with varying-size displays, impaired vision and screen-reading software).