Reputation: 23
I'm asking about the reason for using YAML for package managing pubspec.yaml
in Dart, why did they choose YAML, not JSON? what is the unique thing in YAML that makes it a favourite for this purpose instead of another?
Upvotes: 2
Views: 314
Reputation: 71
they're using YAML to make your life difficult when you want to add fonts or something like this. sometimes you will waste 15 minutes with the indentation which is counter productive tbh.
Upvotes: 0
Reputation: 12364
I'm one of the two people who designed pub and the pubspec.yaml format.
We chose YAML over JSON because JSON doesn't officially support comments and we wanted a configuration file that let users comment out parts of it temporarily and add comments explaining things.
At the time, YAML was one of the most popular config file formats and supported everything we needed and more. In general, it works well for our needs, though I do wish it was simpler and a little less brittle.
If JSON supported comments, we would have used it.
Upvotes: 0
Reputation: 4576
The design goal of JSON is to be as simple as possible and be universally usable. This has reduced the readability of the data, to some extent. In contrast, the design goal of YAML is to provide a good human-readable format and provide support for serializing arbitrary native data structures.
Source: JSON vs. YAML: A Dive Into 2 Popular Data Serialization Languages
Upvotes: 0
Reputation: 456
In my opinion:
YAML is much better... Like Python
In JSON you can't give comments For flutter/Dart application maintenance, of course requires comments since the PUBSPEC file was created.
Indeed JSON files are smaller and faster, but for cross-platform developers, more emphasis on ease of reading and speed of production. Moreover, the development of mobile hardware is now very good.
JSON structure is simpler, so it does not support complex configurations.
But, YAML... be aware that "white space" (tabs v spaces) matters.
Upvotes: 1
Reputation: 445
What is the difference between YAML and JSON?
Most importantly support for comments & Better readability
Upvotes: 0