Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I can't help but think it's funny that Sublime Text uses

- XML for snippets (https://github.com/sublimehq/Packages/blob/master/C%2B%2B/fo...)

- YAML for syntax files (https://github.com/sublimehq/Packages/blob/master/C%2B%2B/C%...)

- JSON for settings (https://github.com/sublimehq/Packages/blob/master/C%2B%2B/C%...)

- and plist for TextMate compatibility (https://github.com/sublimehq/Packages/blob/master/C%2B%2B/In...)

Of course each one has a reason to be that way, but it must be really annoying to maintain.



YAML is a superset of JSON, so those might be processed by the same parser.


That's an error prone way of doing things. People will start putting yaml in their json. Better to just call it yaml then.


Well, the file doesn't actually say what format it's in; from what I can tell, the previous poster just assumed it was JSON from the syntax.


That’s not true; YAML is completely seperate.


No, it's not. See my post downstream. Every JSON file is a valid YAML file.

Example: using PyYAML to parse the JSON file from above:

  >> import yaml
  >> val = yaml.load('{"extensions": ["cpp", "cc", "cxx", "c++", "h", "hpp",
                                      "hxx", "h++", "inl", "ipp"]}')
  >> print val
  {'extensions': ['cpp', 'cc', 'cxx', 'c++', 'h', 'hpp', 'hxx', 'h++', 'inl', 'ipp']}


Wow, interesting. Why do people use YAML syntax then? I find JSON much simpler, less ambiguous. Much prefer JSON for configuration over YAML.


Mostly, I'd say people who prefer YAML-specific syntax (myself included) think it's generally more readable and easier to write. It's also easier to keep clean commits (no trailing comma issue).

That said, I think http://json5.org/ is a decent middle term.


Correct. YAML and JSON can be parsed into the same tree structure but are completely separate syntaxes.


No, they aren't. From the YAML site [emphasis mine]:

"YAML can therefore be viewed as a natural superset of JSON, offering improved human readability and a more complete information model. This is also the case in practice; every JSON file is also a valid YAML file."

http://yaml.org/spec/1.2/spec.html#id2759572

You can parse any JSON file using a YAML parser.


I … OK, I recind my earlier statement! TIL :)


Oh it is. I imagine that Jon has plans to consolidate this mess, but it'd take a while to update the thousands of packages being maintained.

One step at a time!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: