Re: [Powertop] Why C++ is the language of implementation?
Srinivas Pandruvada <srinivas.pandruvada at linux.intel.com>
| Newsgroups | dev.linux.lists.powertop |
|---|---|
| Message-ID | <[email protected]> |
On 03/31/2014 08:43 AM, Bill Vyzas wrote: > Hi all, > > I am curious to know why PowerTOP is using C++ as the language of > implementation but the majority of the program is written with the C > standards. I checked also some other open source programs like the Gnome > Power Manager and its doing the same thing. > > I know that C++ can also call C and I also know that there are couple of > classes on the program but why use C++ for a few classes when you can have > structs, which are basically classes, instead. It is because of ease of implementation using inheritance and polymorphism. For example you can have a common device class and other device CPUs are expanding the capability of a basic device. Also for common code all objects are devices, if it happens to be a CPU, then cpu specific methods can be called. Also it provides a very easy path for enhancements, without touching the core functionality. You can do in C with struct and function pointers, but implementing in C++ is easy. Thanks, Srinivas > Thanks, > Bill > > > > _______________________________________________ > PowerTop mailing list > PowerTop(a)lists.01.org > https://lists.01.org/mailman/listinfo/powertop
attachment.html
(text/html, 2 KB)
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 03/31/2014 08:43 AM, Bill Vyzas
wrote:<br>
</div>
<blockquote
cite="mid:CADy9ZNA_1wW69nyNNS=yqL0iqoWZZB=UiTt2BCkft=nqwZP5Sg@mail.gmail.com"
type="cite">
<pre wrap="">Hi all,
I am curious to know why PowerTOP is using C++ as the language of
implementation but the majority of the program is written with the C
standards. I checked also some other open source programs like the Gnome
Power Manager and its doing the same thing.
I know that C++ can also call C and I also know that there are couple of
classes on the program but why use C++ for a few classes when you can have
structs, which are basically classes, instead.
</pre>
</blockquote>
It is because of ease of implementation using inheritance and
polymorphism.<br>
For example you can have a common device class and other device CPUs
are<br>
expanding the capability of a basic device. Also for common code all
objects are<br>
devices, if it happens to be a CPU, then cpu specific methods can be
called.<br>
Also it provides a very easy path for enhancements, without touching
the core<br>
functionality.<br>
You can do in C with struct and function pointers, but implementing
in C++ is easy.<br>
<br>
Thanks,<br>
Srinivas<br>
<br>
<blockquote
cite="mid:CADy9ZNA_1wW69nyNNS=yqL0iqoWZZB=UiTt2BCkft=nqwZP5Sg@mail.gmail.com"
type="cite">
<pre wrap="">
Thanks,
Bill
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
PowerTop mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://lists.01.org/mailman/listinfo/powertop">https://lists.01.org/mailman/listinfo/powertop</a>
</pre>
</blockquote>
<br>
</body>
</html>