Something is wrong with the YAML format that needs to be attached to web standards

Well, I think YAML is really fantastic ...

This is a beautiful, easy to read, smart syntax ... compared to any other data serialization format. As a superset of JSON we could say that it is in more detail, therefore, its evolution of the language.

But I see several different opinions, for example:

  • Yaml is dead
  • do not use yaml etc.

I just can't figure out what it's based on, because it seems so enjoyable :)

If we take some good examples on the Internet, such as Ruby on Rails , we know that they use yaml for easy customization, but one thing that interests me is why yaml is not part of most of the formats used over the web , such as XML and JSON.

If you take twitter, for example ... why not offer YAML data from the API?

Is there something wrong with doing this?

We can see evolution in no-sql databases such as couchdb , mongo , all json-based, even one large project called jsondb that looks very lightweight and it can definitely do the job.

But when writing data structures in json, I really can't understand why YAML is not used instead.

So, one of my problems will be if something is wrong with YAML?

People may say this is complicated, but well, if you pretend to use the same functions as json , it is definitely not . You will get a more beautiful file for confidence and without any extra hassle. It would be really more complicated if you decide to use more features, but be that as it may, at least you have the option to use it if you want.

Being able to choose whether or not to use double quotes for a string is fantastic, makes it all cleaner and easier to read .... well, you see, my point :)

So my question is: why is YAML not used mainly instead of JSON ?

Why doesn’t it seem that it will be used to transmit data in the online community?

All I see are people who use it for simple configuration files, and nothing more ...

Please bear with me, as I may be completely wrong, and there may be very large projects, and my ignorance on this issue did not allow me to be part of it :)

If there is any big project based on the barley, I would be very happy to know about it

Thank you in advance

+4
source share
5 answers

It’s not that something is wrong with YAML — it’s just that in many cases it does not offer any convincing benefits. YAML is basically a superset of JSON. For most purposes, JSON is sufficient: people will not use the advanced YAML functions, even if they have a full YAML parser, and its close connection with JavaScript makes it well fit into the technologies that web developers use anyway.

TL; DR: People already use as much YAML as they need. In most cases, this is JSON.

+3
source

In Ruby, many argue that the configuration should be Ruby, not YAML. This saves the parsing stage, meaning you don’t need to learn new syntax or use ERB tags everywhere when you dynamically generate YAML content (Rails devices).

Personally, I have to agree and cannot see what YAML will offer to network transmissions, which would make it worth considering JSON consideration.

+2
source

YAML uses more data than non-confidential JSON. This is great for files that people might want to edit, but when all you do is transfer data, you lose bandwidth if you use YAML.

If you need an explanation: each space in UTF-16 is two bytes. YAML uses spaces for indentation and newlines for nesting.

Take this example:

 foo: bar: - foo - bar 

This requires 44 characters (including newlines). Equivalent JSON will be only 29 characters:

 {"foo":{"bar":["foo","bar"]}} 

Then imagine what happens if you encode the YAML URL. It is 95 characters long:

 foo%3A%0A%20%20%20%20bar%3A%0A%20%20%20%20%20%20%20%20-%20foo%0A%20%20%20%20%20%20%20%20-%20bar 

Meanwhile, JSON just becomes 64 characters:

 %7B%22foo%22%3A%7B%22bar%22%3A%5B%22foo%22%2C%22bar%22%5D%7D%7D 

The increase in size to YAML from JSON is more than doubled when it is encoded by the URL in the example above. And I am sure that you can imagine that the longer your YAML file, the greater this difference will increase.

Oh, and another reason not to use YAML: stackoverflow.com does not support YAML syntax highlighting ...! (Of course, I would say that YAML is so beautiful that it doesn’t work. It requires syntax highlighting. This is the point of view of YAML, I think.)

+2
source

YAML has a lot of problems, there is a good YAML article : probably not so good at that. Brief summary (besides the problems listed in other answers):

  • Unreadable except simple and short things
  • Unsafe by default
  • Portability problems
  • Very complex with unexpected behavior
+1
source

I have considered using YAML several times and never did. The reason has always been spaces for indentation. Although I personally love it, even for me it sounded like a request for trouble, because

  • Of course, someone will make a mistake, not expecting that changing spaces will cause the file to break. Sometimes someone who has no idea about the language / format needs to go to the file to change one number or line.
  • You cannot guarantee that all users will have comparison / merge / SC software configured properly to catch spaces or difference in blank lines.
0
source

Source: https://habr.com/ru/post/1343863/


All Articles