5 ms·
I use YAML as human-editable JSON - especially for non-programmers (although it's surely more pleasant to write even for programmers). I would like a clearly d
by andybak 10y ago
I use YAML as human-editable JSON - especially for non-programmers (although it's surely more pleasant to write even for programmers).
I would like a clearly documented YAML subset that left out some of the more complex stuff and avoided a few 'more than one way to do it' features. That would go a long way to removing some of the criticism of YAML with very little cost in functionality.
- espadrine 10y ago> I would like a clearly documented YAML subset that left out some of the more complex stuff and avoided a few 'more than one way to do it' features. That's the goal of dotset (https://github.com/espadrine/dotset https://github.com/espadrine/dotset).
- byuu 10y agoI made BML for that purpose. I posted about it before: https://news.ycombinator.com/item?id=8645591 https://news.ycombinator.com/item?id=8645591 To copy-paste the example: server path: /core/www/ host: example.com port: 80 service: true proxy host: proxy.example.com port: 8080 authentication: plain description :Primary web-facing server :Provides commerce-related functionality server ... proxy host="proxy.example.com" port=8080 authentication: plain There's no character escaping, brackets, distinction between attributes and elements, data types (up to the one parsing the document how to decode values), etc. BOM-free UTF-8 is mandatory. It's the bare minimum for an extensible tree-based data structure, but I threw in three ways to assign values to nodes to help craft smaller documents. Turns out it's hugely important to be able to assign multiple child nodes on the same line as the parent for certain classes of documents. My implementation of BML uses my string library, so I can't offer a portable parser. But it shouldn't take more than an hour or two to write a BML parser. Still, my reference example is here: https://gitlab.com/higan/higan/tree/master/nall/string/markup https://gitlab.com/higan/higan/tree/master/nall/string/marku... -- 177 lines for the base parser, which can also save back modified BML documents. Downside is that I have no clue how to market it, and I hate writing documentation, so there's only a few people using it.
- amyjess 10y ago> Downside is that I have no clue how to market it, and I hate writing documentation, so there's only a few people using it. You could always write up a quick demo program (something anyone can just clone, compile, and execute), throw in a few example files, and submit your repository as a Show HN. That might get some attention at least.
- mjevans 10y agoI completely DISAGREE with this. My experience with YAML is that it's very temperamental with respect to /whitespace/ and that your editor might try to get too smart and damage the document. JSON, if you see a pattern and follow the pattern, is likely to work. JSON CAN be stored in a 'pretty' way, with extra whitespace, which makes it even more obvious how to format a document; that's frequently how I write out small bootstrap config files (IE the database connection string to get the main config from).
- dietrichepp 10y agoCan you give an example of where an editor has damaged your documents? I've never had that experience when editing YAML with Vim, Emacs, or TextMate… which editor are you using?
- mjevans 10y agoFocusing on the editor won't help because then you're adding an unexpected constraint on the user. I think I happened to experience it using kwrite, or maybe also notepad++ when I had to edit something from a non-default computer once. The point still remains that editors which /try/ to be smart and helpfully correct, convert, or automatically indent things, won't always do it the way you might have wanted. What works in one context won't work in others, and having context sensitive whitespace handling can bite you when the program isn't aware of which context it's supposed to be crafting the document in (EG when you start a new one or copy an example from the web).
- bbcbasic 10y agoI hate it when languages and formats care about whitespace beyond just whether there is some between two tokens. Not being able to use tabs in Haskell is annoying for example. And I find having to indent stuff so it is off the page to the right to get stuff to compile unsatisfactory. Same with YAML. I detest a format where indenting matters. It shouldn't matter.
- deleted 10y ago
- danso 10y agoI completely agree with this. I use YAML as a way to write structured data that may be serialized into JSON at another endpoint (mostly because JSON is much more universal and what does it matter to me how exactly my data is serialized by another machine). I know of its other features but haven't found the need to try them, yet every security hole those features make possible ends up limiting the acceptance of YAML.
- networked 10y ago>I would like a clearly documented YAML subset that left out some of the more complex stuff and avoided a few 'more than one way to do it' features. I looked for one some months ago and the closest I found was https://github.com/crdoconnor/dumbyaml https://github.com/crdoconnor/dumbyaml, which is a parser implementation, not a standard. Out of projects approaching the issue from the opposite angle ("smarter JSON"), I think HOCON (https://github.com/typesafehub/config/blob/master/HOCON.md https://github.com/typesafehub/config/blob/master/HOCON.md) is the most promising. Compared to Hjson (http://hjson.org/ http://hjson.org/), it is less likely to confuse the user with how trailing commas are treated in unquoted strings and generally appears to not compromise on strictness for convenience. That said, I agree with TillE: as soon as a configuration file format I work on needs any logic or expressions I will strongly consider an embedded scripting language like Lua or Tcl in order to avoid instantiating Greenspun's tenth rule for configuration.
- ch4s3 10y agoI rather like TOML https://github.com/toml-lang/toml https://github.com/toml-lang/toml
- ak217 10y agoWe need this so much. YAML is by far the best choice for human-readable and editable serialization, but the bells and whistles are really unnecessary and hold back innovation among the parser packages.
- crdoconnor 10y agoInnovation like what?