* [Qemu-devel] new to qemu with a simple question
@ 2017-05-24 2:56 Wang Dong
2017-05-24 3:11 ` Fam Zheng
2017-05-24 13:30 ` Eric Blake
0 siblings, 2 replies; 5+ messages in thread
From: Wang Dong @ 2017-05-24 2:56 UTC (permalink / raw)
To: qemu-devel
Hi guys,
I am new to qemu. But I need do some job in it right now.
When I try read qmp code. I found a interesting part against it.
Some C source code is generate from json file.
I wonder why this? What is the benefits of this?
Thanks in advance.
--
Best regards. Wang Dong
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] new to qemu with a simple question
2017-05-24 2:56 [Qemu-devel] new to qemu with a simple question Wang Dong
@ 2017-05-24 3:11 ` Fam Zheng
2017-05-24 8:37 ` Wang Dong
2017-05-24 13:30 ` Eric Blake
1 sibling, 1 reply; 5+ messages in thread
From: Fam Zheng @ 2017-05-24 3:11 UTC (permalink / raw)
To: Wang Dong; +Cc: qemu-devel
On Wed, 05/24 10:56, Wang Dong wrote:
> Some C source code is generate from json file.
>
> I wonder why this? What is the benefits of this?
This allows you to concentrate on the high level semantics of the QMP API,
without worrying about C syntax and structural code here and there. In one
word, more conciseness and little code duplication.
If done in C, it would be much more lines of code and hardly readable.
Fam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] new to qemu with a simple question
2017-05-24 3:11 ` Fam Zheng
@ 2017-05-24 8:37 ` Wang Dong
0 siblings, 0 replies; 5+ messages in thread
From: Wang Dong @ 2017-05-24 8:37 UTC (permalink / raw)
To: Fam Zheng; +Cc: qemu-devel
Thank you, Fam.
On 05/24/2017 11:11 AM, Fam Zheng wrote:
> On Wed, 05/24 10:56, Wang Dong wrote:
>> Some C source code is generate from json file.
>>
>> I wonder why this? What is the benefits of this?
> This allows you to concentrate on the high level semantics of the QMP API,
> without worrying about C syntax and structural code here and there. In one
> word, more conciseness and little code duplication.
>
> If done in C, it would be much more lines of code and hardly readable.
>
> Fam
>
--
Best regards. Wang Dong
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] new to qemu with a simple question
2017-05-24 2:56 [Qemu-devel] new to qemu with a simple question Wang Dong
2017-05-24 3:11 ` Fam Zheng
@ 2017-05-24 13:30 ` Eric Blake
2017-05-26 4:54 ` Wang Dong
1 sibling, 1 reply; 5+ messages in thread
From: Eric Blake @ 2017-05-24 13:30 UTC (permalink / raw)
To: Wang Dong, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]
On 05/23/2017 09:56 PM, Wang Dong wrote:
>
> Hi guys,
>
> I am new to qemu. But I need do some job in it right now.
>
> When I try read qmp code. I found a interesting part against it.
>
> Some C source code is generate from json file.
>
> I wonder why this? What is the benefits of this?
Boring and repetitive code that is easy to typo is best written by a
computer, which excels at boring and repetitive tasks. Writing our
description in a more concise higher language and generating C code from
that lets us focus on the actual design, rather than the mundane
correctness of the code implementing the design.
It's the same reason that people use bison/yacc rather than hand-written
parsers for complex grammars - you isolate the correctness of the code
to the correctness of the generator, and free yourself to now only have
to worry about the bigger picture of the input you feed to the
generator. And on another level, it's why we write programs in C
instead of assembly. Abstraction is good.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] new to qemu with a simple question
2017-05-24 13:30 ` Eric Blake
@ 2017-05-26 4:54 ` Wang Dong
0 siblings, 0 replies; 5+ messages in thread
From: Wang Dong @ 2017-05-26 4:54 UTC (permalink / raw)
To: Eric Blake, qemu-devel
On 05/24/2017 09:30 PM, Eric Blake wrote:
> On 05/23/2017 09:56 PM, Wang Dong wrote:
>> Hi guys,
>>
>> I am new to qemu. But I need do some job in it right now.
>>
>> When I try read qmp code. I found a interesting part against it.
>>
>> Some C source code is generate from json file.
>>
>> I wonder why this? What is the benefits of this?
> Boring and repetitive code that is easy to typo is best written by
> computer, which excels at boring and repetitive tasks. Writing our
> description in a more concise higher language and generating C code from
> that lets us focus on the actual design, rather than the mundane
> correctness of the code implementing the design.
>
> It's the same reason that people use bison/yacc rather than hand-written
> parsers for complex grammars - you isolate the correctness of the code
> to the correctness of the generator, and free yourself to now only have
> to worry about the bigger picture of the input you feed to the
> generator. And on another level, it's why we write programs in C
> instead of assembly. Abstraction is good.
>
Thanks for your reply. I really appreciate it.
--
Best regards. Wang Dong
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-26 4:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 2:56 [Qemu-devel] new to qemu with a simple question Wang Dong
2017-05-24 3:11 ` Fam Zheng
2017-05-24 8:37 ` Wang Dong
2017-05-24 13:30 ` Eric Blake
2017-05-26 4:54 ` Wang Dong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).