All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] Non-flat command line option argument syntax
Date: Fri, 3 Feb 2017 21:28:22 +0100	[thread overview]
Message-ID: <bfb329d2-245f-8175-7f02-7f806d022d99@redhat.com> (raw)
In-Reply-To: <87bmukmlau.fsf@dusky.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 3224 bytes --]

I like both JSON and dot syntax. But I like them differently in
different places.

I love JSON when it's in some file where I can turn out syntax
highlighting and let my $EDITOR match brackets and braces.

I hate JSON when it's on the command line. You have to escape, you get
strings in strings, and at least for QMP you sometimes even get strings
in strings in strings (yes, I like my "echo | qemu -qmp stdio" with
human-monitor-command). Apart from that, usually I don't format anything
nicely on the command line anyway, so JSON and dot syntax are equally
illegible then.

JSON is great for reading, when formatted correctly. If it's not
formatted nicely and you don't have a good editor with highlighting,
it's pretty bad.
It's good for writing in an editor. It's not so nice for writing in a shell.

OTOH, it's hard to read dot syntax when formatted correctly and it's
just as bad as JSON when it isn't. But even if you have an editor at
hand, you can't make it better.
It's very easy to write dot syntax, however. Just write down what you
want. Oh, forgot a parameter for that dict three arrays ago? Just write
it down now. Doesn't matter where you put it. How many braces do I need
to close now? Oh, right, I don't need to close any. Nice!

So dot syntax is pretty much a write-only syntax. But it's very good at
that.

On the command line I absolutely adore the dot syntax. It doesn't force
you to quote, you can put everything anywhere and you don't need to
count braces. I love it.

However, nobody can read what you wrote. Usually doesn't matter. But for
docs, that's bad. For scripts, it depends, but again, it usually is bad.
For configuration files, there is pretty much no excuse. So in general,
I'm very skeptic about dot syntax in files, to say the least.


So I think it would be good to allow full-JSON configuration. Put it in
a file, great.

But at the same time, I do not think that JSON is good for the command
line. Dot syntax works fine and in my opinion it often doesn't actually
matter whether it's legible or not.


I don't like structured values very much because to me they are just
"JSON light". Well, you don't have to quote keys and values (so no
"string in string" mess), but other than that you still have to quote
everything and you still have to count braces.

Max


PS: I personally actually think that structured representations such as
JSON may in some situations be less legible than the dot syntax if you
do not have syntax highlighting and it's not formatted nicely; and
that's because you have to count braces not just when writing but also
when reading. Imagine the following:

a.b.c.d.e.f=42,a.b.c.g=23

{"a":{"b":{"c":{"d":{"e":{"f":42}}},"g":23}}}

I can read the first one much better than the second one. Of course,
that's different with nice formatting and a good editor, but the above
is how I would write it on the command line.

I know it's a fabricated example and you'd just need to switch "g" and
"d", but "}}}}}}" actually makes me a bit dizzy, so that may be even
worse. Anyway, I just wanted to make the point that I think that compact
JSON and dot syntax are both pretty much illegible.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

  parent reply	other threads:[~2017-02-03 20:28 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 19:42 [Qemu-devel] Non-flat command line option argument syntax Markus Armbruster
2017-02-02 20:06 ` Eric Blake
2017-02-02 20:23 ` Eric Blake
2017-02-03  7:57   ` Markus Armbruster
2017-02-02 20:27 ` Dr. David Alan Gilbert
2017-02-03  7:50   ` Markus Armbruster
2017-02-03 16:57     ` Dr. David Alan Gilbert
2017-02-04  9:44       ` Markus Armbruster
2017-02-06 10:20         ` Dr. David Alan Gilbert
2017-02-03 20:02     ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-04  9:45       ` Markus Armbruster
2017-02-04 10:03         ` [Qemu-devel] " Paolo Bonzini
2017-02-04 11:52           ` Markus Armbruster
2017-02-04 12:43             ` Paolo Bonzini
2017-02-03 10:03 ` Daniel P. Berrange
2017-02-03 11:13   ` Markus Armbruster
2017-02-03 12:37 ` Peter Krempa
2017-02-03 13:53   ` Markus Armbruster
2017-02-03 17:25 ` Richard W.M. Jones
2017-02-04  9:51   ` Markus Armbruster
2017-02-05 20:46     ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-03 20:28 ` Max Reitz [this message]
2017-02-04  9:56   ` Markus Armbruster
2017-02-04 12:21 ` [Qemu-devel] " Fam Zheng
2017-02-04 12:44   ` Paolo Bonzini
2017-02-04 13:02     ` Fam Zheng
2017-02-04 13:35   ` Markus Armbruster
2017-02-04 14:10     ` Fam Zheng
2017-02-06  6:24       ` Markus Armbruster
2017-02-06 11:08   ` Daniel P. Berrange
2017-02-06  6:57 ` Markus Armbruster
2017-02-06 13:23 ` Kevin Wolf
2017-02-06 15:36   ` Markus Armbruster
2017-02-06 16:33     ` Daniel P. Berrange
2017-02-06 17:24       ` Markus Armbruster
2017-02-06 17:50         ` Daniel P. Berrange
2017-02-06 18:56           ` Markus Armbruster
2017-02-06 17:38     ` Paolo Bonzini
2017-02-06 18:12       ` Markus Armbruster
2017-02-06 21:52         ` Paolo Bonzini
2017-02-07  7:02           ` Markus Armbruster
2017-02-07  9:26     ` Kevin Wolf
2017-02-24 16:04 ` Markus Armbruster
2017-02-24 16:39   ` Daniel P. Berrange
2017-02-24 17:17     ` Eric Blake
2017-02-24 19:15       ` Markus Armbruster
2017-02-27 10:27 ` Markus Armbruster
2017-02-27 10:59   ` Kevin Wolf
2017-02-27 13:36     ` Markus Armbruster
2017-02-27 19:47       ` Eric Blake
2017-02-28  8:24         ` Markus Armbruster
2017-02-27 19:43   ` Eric Blake
2017-02-28  8:41     ` Markus Armbruster
2017-03-01  9:24 ` Markus Armbruster
2017-03-21  8:40 ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bfb329d2-245f-8175-7f02-7f806d022d99@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.