qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] Non-flat command line option argument syntax


From: Max Reitz
Subject: Re: [Qemu-block] Non-flat command line option argument syntax
Date: Fri, 3 Feb 2017 21:28:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

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: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]