News for hackers. Stuff that matters.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by SomeCallMeTim on Sunday July 31, 2016 @04:41PM (#12198736)
>In those cases, I would rather have XML config files than undocumented binary blobs as config files.

False dichotomy.

Better than XML and binary blobs:

* JSON (assuming everyone knows what this is)

* YAML [0]

* Lua tables (if you're already using Lua as a scripting language; Lua started out as a configuration language after all)

* INF format [1] (not my favorite, but pretty easy to parse and much better for humans to read than XML)

* Any of the above compressed with a gzip compatible compression (if size matters, though it rarely does these days)

Even Protocol Buffers [2] are better than XML, though at that point it becomes a "documented binary blob". But as long as the spec is shared, the format can easily be read by just about any programming language.

[0] https://en.wikipedia.org/wiki/YAML

[1] https://en.wikipedia.org/wiki/INF_file

[2] https://en.wikipedia.org/wiki/Protocol_Buffers

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by flukus on Sunday July 31, 2016 @07:54PM (#12199490)
> JSON (assuming everyone knows what this is)

The new .net uses json, it's awful. No comments allowed and it get's pretty unreadable when you have nested configuration elements.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by ivl on Sunday July 31, 2016 @10:25PM (#12199904)
I seriously think the lack of comments is a deal breaker for JSON config files for me. At least with what I'm doing now. I find myself changing configs a ton, and I love being able to simply change which blocks are commented to get what I want, without having to dig anywhere.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by SomeCallMeTim on Tuesday August 02, 2016 @01:38AM (#12207989)
I agree...and I found a Gulp plugin that lets me pre-strip comments from my JSON files as part of the build process.

So I use JSON-with-comments, but the app only sees the stripped files.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by piaste on Monday August 01, 2016 @01:43AM (#12200411)
VSCode uses comments for every line in its settings.json file.

I guess they figured it may not be correct JSON, but since they aren't sending those particular JSON files anywhere it doesn't matter?

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by Perseids on Monday August 01, 2016 @05:12AM (#12201039)
JSON5 [1] is an extension to JSON that allows comments, multi line strings, additional commas at the ends of lists, and more. It has become my preferred config file format.

[1] http://json5.org/

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by DiabloD3 on Sunday July 31, 2016 @10:02PM (#12199847)
And instead of Protobufs, Cap'n Proto [1], which was started by one of the principal author behind Protobufs, to fix all the flaws in Protobufs.

[1] https://capnproto.org/

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by int_handler on Sunday July 31, 2016 @10:38PM (#12199937)
You can use Protocol Buffers for configs without having to serialize them in its binary format. Protocol Buffers has always had its own text format [0] and now a JSON mapping [1] as well.

The proto text format is actually more flexible and less verbose than JSON since it does not require the outer enclosing set of braces and quotes around all the keys and has support for comments.

Here are a couple of examples of config files using the Protocol Buffers text format:

* Bazel CROSSTOOL: https://github.com/bazelbuild/bazel/blob/master/tools/cpp/CR...

* SyntaxNet: https://github.com/tensorflow/models/blob/master/syntaxnet/s...

[0] https://developers.google.com/protocol-buffers/docs/overview...

[1] https://developers.google.com/protocol-buffers/docs/proto3#j...

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by andrewflnr on Sunday July 31, 2016 @05:38PM (#12199014)
GP is obviously not stupid enough to think that XML and binary are the only options. Their whole point seemed to be that they've seen enough binary blobs in practice that even XML was a welcome step up.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by chriswarbo on Monday August 01, 2016 @05:57AM (#12201209)
I've always considered YAML to be far too complicated. There are many overlapping/redundant syntax rules for doing the same thing, lots of ways to mess up parsing, etc.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by crdoconnor on Monday August 01, 2016 @06:26AM (#12201289)
True, but if you turn those "features" off and swap out implicit typing for explicit typing it becomes a much simpler language.

This is what I ended up doing:

https://github.com/crdoconnor/strictyaml

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by moosingin3space on Monday August 01, 2016 @01:35PM (#12204314)
I'd say TOML [0] is the best because it can be a very simple key=value structure, but also supports very detailed, nested structures. It has a 1-to-1 correspondence with JSON, but is more friendly for configuration (comments are a huge help!)

[0]: https://github.com/toml-lang/toml

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by chme on Monday August 01, 2016 @06:50AM (#12201400)
I am missing a config file format / parser&generator lib that preserves every comment and format (empty lines, etc.) after a read/write cycle.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by SomeCallMeTim on Tuesday August 02, 2016 @01:41AM (#12208001)
I've written that for Lua files. And I've seen it for XML, to be fair.