introspection

rony rony at wu.ac.at
Thu Jan 25 16:29:19 UTC 2018


On 25.01.2018 14:40, Simon McVittie wrote:

> On Thu, 25 Jan 2018 at 19:51:59 +1300, Lawrence D'Oliveiro wrote:
>> On Wed, 24 Jan 2018 18:00:28 -0800, Thiago Macieira wrote:
>>> In any case, depending on runtime introspection is usually bad coding 
>>> practice.
>> Wonder why it was part of the spec, then?
> It's a debugging/development feature for use by generic tools that
> cannot be expected to have domain-specific knowledge. For example,
> the interactive D-Bus debugger "D-Feet" uses it to display object trees
> and their methods, and the gdbus(1) tool supplied by GLib uses it for
> tab-completion. You can think of it as the D-Bus equivalent of DWARF
> debug symbols: they're very useful for gdb and valgrind, but if C/C++
> application code relies on introspecting the libraries that it uses via
> their debug symbols, then something has gone horribly wrong.
>
> Clients that *do* have domain-specific knowledge (anything that isn't a
> debugging tool) should avoid relying on introspection - their
> domain-specific knowledge should ensure that they don't *need*
> introspection, because they already know what to expect. For example, an
> MPRIS2 client already knows what the MPRIS2 interfaces look like, and
> doesn't need Introspect() to tell it.
>
> It was also less clear at the time introspection was designed (we're
> talking about more than 10 years ago) how bad an idea it was to use it
> outside debugging tools: one major "production" user of introspection is
> dbus-python, which is almost as old as dbus, and is unable to stop using
> introspection to guess types without it being a major compatibility break.

One application area where - even with domain-specific knowledge - the introspection data is very
handy and useful is that of dynamically typed (scripting) languages.

If such a language e.g. uses strings to represent all kind of numeric values (like Rexx) than it is
a huge relief for the (Rexx) programmer if she does not have to programmatically ("manually") do the
necessary type conversions for interacting with DBus but have the DBus2ooRexx bridge do that behind
the scenes, which introspection allows for. The relief for the programmer in this environment is
immense.

Therefore I think that introspection is really a great feature of DBus for dynamically typed
languages, even if most DBus applications might use statically typed and compiled languages that can
do without dynamic introspection.

---rony


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20180125/c5df4c9b/attachment.html>


More information about the dbus mailing list