4 ms·
Feature not a bug. YAML is what people turn to who need these kind of advanced feautures which arent provided in json or similar.
by twelvechairs 10y ago
Feature not a bug. YAML is what people turn to who need these kind of advanced feautures which arent provided in json or similar.
- OskarS 10y agoI would imagine this feature is primarily useful if you want to serialize a whole bunch of objects that all reference each other, but it makes me feel a bit icky. It feels like it breaks an intuitive assumption you have about hierarchical formats, which is that there should be no cycles. Maybe that's just my personal bias, but I feel like the relative simplicity of JSON is a strong feature in its favor. As a developer, I have very clear understanding of the data I'm reading, and with that I can more easily make safer and more stable code.
- junke 10y agoYet, a lot of hierarchical structures I see are full of "ref" and "id" attributes, which effectively encode cyclic graphs.
- OskarS 10y agoThat's certainly true, but at least that's not going to cause an infinite loop while wandering down the structure, it's just gonna end at a leaf "ref" or "id".
- junke 10y agoIn my view this is more a question of simple interface vs. simple implementation. Having cross-references at the language level gives a uniform and simplified interface at the cost of more having to develop careful tools. Not saying refs/id are bad, but at least with a uniform syntax and language support, you don't have to reimplement custom cross-reference resolvers.
- twelvechairs 10y agoYou are right for most use cases - which is why json is so popular. Sometimes however there is very good reason to have non-hierarchical data - and YAML fits this use case.
- crdoconnor 10y ago>YAML is what people turn to who need these kind of advanced feautures Most people don't use these features.
- Sir_Substance 10y agoBut twelvechairs' contention is that the people who do need them turn to YAML :)
- crdoconnor 10y agoExcept the people who use YAML don't seem to use them: https://github.com/search?o=desc&p=2&q=data+language%3AYAML&ref=searchresults&s=indexed&type=Code&utf8=%E2%9C%93 https://github.com/search?o=desc&p=2&q=data+language%3AYAML&...
- kelseyfrancis 10y agoI'm not sure what your search query is supposed to prove. That something is rare doesn't mean it doesn't exist. I have personally used this YAML feature, albeit very rarely, obviously.
- timv 10y agoHis query is attempting to show that while > YAML is what people turn to who need these kind of advanced feautures might be literally true, it is also true that YAML is what many people turn to even if they don't use those features So the original concern of > Powerful but pretty catastrophic if you use (naive) recursion to analyze a user-submitted data structure. is probably reasonable. There is a pretty good likelihood that many YAML users (i.e. the app developers) are unaware of the power exposed in the format, and the possible consequences of parsing & walking user input. It brings back all sorts of memories of XML entity attacks, etc. When developers build simple data interchange methods on top of complex formats that they don't fully understand, all sorts of issues emerge. It's not YAML's problem per se - it's very helpful that there is a commonly used, complex data format for people who need such features. It would be far worse if everyone was inventing their own solution for this - but the reality on the ground is still pretty messy.
- techdragon 10y agoIn my experience, YAML is what people turn to when they want something like JSON, but don't want to have to type the extra braces and quotation marks.
- untog 10y agoThat's certainly my use case. Things like easy multi-line strings make it very useful, and readable by less tech-inclined folks. Though for that audience ArchieML is better still: http://archieml.org http://archieml.org