Together with this tech preview, Harald Fernengel released a preview of a brand new set of D-BUS bindings. Using Qt's meta object system, broadcasting signals and invoking methods in other applications is now a breeze. D-BUS signals can be connected to any slot. No preprocessor and no special wrapper classes are necessary. You can download the library at the Qt D-BUS tutorial page.

> While it's true that C++ provides quite a bit more safety over C, it's still
> as easy to produce insecure code with C++ as much as it is with C.

Do you actually read what you type? You dont make sense.

It is way easier to write (and read!) C++ code than C, while C++ can even be slightly faster than C.
But my point is not that C++ is the best language ever made (even though its pretty good), my point is that you should not use a 30-40 years old technology like C for todays programs.

Since C is an almost complete subset of C++, most C statements are valid C++ and your niffty C++ code probably uses quite some elements from that subset. The anonymous poster is right in saying that producing insecure C++ code is very easy. Of course you can always compensate this insecurity by using strict conventions, but this is possible in C as well. Bashing some project just because it is developed using a certain language is quite unhelpful to say the least. Remember your trustworthy Linux kernel is C code as well and even the C++ based KDE had security issues in the past. That being said I consider myself a C++ programmer but not the kind of language fascist that you seem to be.

I wonder if any of you people have even looked at the dbus code ?? - I have and it looks well written, so why not just accept that some cool programs is written in C and others in C++ (and Haskell, and Java, and C#, and ....).

As for the 30-40 year old technology, I can tell you that this old stuff powers most of the operating system kernels around the world today (inluding Linux, FreeBSD and big parts of the NT kernel) - but then again you can always try to convince Linus, Alan and the rest of the Linux gang to rewrite it in C++.

Ohh do you really mean that reading C++ is easier than C ?. Given that the grammars/lexical defenitions for C++ is much more complex than C, and most people writing programs in C++ only have marginal understaning of the language.

> I wonder if any of you people have even looked at the dbus code ?? - I have and it looks well written, so why not just accept that some cool programs is written in C and others in C++ (and Haskell, and Java, and C#, and ....).

last time I checked there was glib code pasted into it, but that was like a year ago or so. Overall I wasn't impressed.

> Ohh do you really mean that reading C++ is easier than C ?

Sure it is. Every C++ program follows roughly the same rules. On the other hand for every C library that I use you have to learn a new "object emulation model" or some more or less crazy API.

> C++ is much more complex than C
Yeah, try reading the boost libraries. Even the STL files, in/usr/include/c++/, can be hard to follow. But don't get me wrong, the result is _very_ powerfull both in features as in speed. But indeed KDE's includes are easy to read.
Actually I was quite happy to only have to recompile libfam and Qt/KDE, when upgrading gcc from 3.3 to 3.4. Not to mention the compile time difference. Long live C, and may every library, that I don't have to use, be implemented in C. And which I do use, well mostly it doesn't really matter.

What's really a swamp is building on top of win32, because you don't know what beneath you (and you get sucked away as soon as it becomes too popular).

No, I chose to drive a car(C++) rather than riding on a horse(C) to work.
But seriously, I know it is hard to compare C libs to C++ libs because there is not very often 2 libraries for the same thing. I chose stl vs glib, because they do roughly the same, I/O, containers, string.

> Oh yeah, being able to interoperate with various GNOME apps is good too.

it's not just GNOME. HAL (hardware abstraction layer) uses DBUS as well to notify from (the Linux) kernel space out about hardware devices (including hotplugging). DBUS is useful to all sorts of apps, not just GUI apps. it is, IMHO, the obvious and logical progression from DCOP, which proved within the confines of the desktop the utility and power of a purpose-built lightweight IPC mechanism, out to the OS in general. people complain about how the desktop is its own little disconnected world on UNIX, and DBUS is one step towards bridging that gap.

so, it's not *just* desktop interop, it's a way to bring a meaningful communication stack across the OS. the ATK DBUS bridge is one such example.

>people complain about how the desktop is its own little disconnected world on UNIX, and DBUS is one step towards bridging that gap.

Emmmh.Perhaps this fact that the gui isn't linked to deep with the os saves us from the experience of hardlocked machines like Windows, if gui apps crash.

Maybe DBUS brings us more possibilities for the Unix desktop, but i hope we don't have to accustom with daily reboots or security holes that find their way to the os through the desktop.I would prefer the desktop as a separate thing (like it is) with not to much power over the os.

Interacting with a messaging bus and deeply integrating poorly abstracted code into the kernel are about as similar as installing phone lines are to building on top of another house. Getting a message or not getting a message where a client is in trouble is not the same as the client code blocking the kernel when it crashes because they are directly linked.

The key here is that a messaging system can provide the benefits with a huge buffering effect reducing the issues to a fraction of the problems possible with deep integration. This should affect your need to reboot about as much as a web site going down unless it's done very poorly.

You didnt understand anything. Its not a language flamewar, its just that the situation on linux et al. is very disapointing technologywise. We are not in the position to cheat IBM once more as MS did, neither has linux the marketshare to afford low quality C libs like Windows.
Everyone is creating modern frameworks in something nice like C++/ObjC(++)/Java/C# or whatever. Look at MacOS X, Sun, or even BeOS. Only free software is mostly crapped up with C. KDE/Qt is one of the few exceptions and that is the reasons why it attracted many developers.

Instead of spitting on C, where is the C++ variant then. DCOP never made it outside KDE AFAIK. And DCOP has it drawbacks, eg. an DCOP object is tied to its application object name. Recently I started using kmix for volume control. But where is the kmix object, inside kicker, somewhere else, or not running at all? These are question you _don't_ want to care about when just wanting to control the volume. Besides, KDE is obsessed with multi-platform. Read the threads, nobody dares to implement hotplug/sysfs, or how are they called, events.
Thanks to Qt taking the lead (and of course work from the dbus/kernel developers!!!), we'll finally have these in KDE.

Then you should have said so instead of calling it a "shitty language" with no further explanation.

Anyway, C++ has its share of problems. The lack of a stable ABI being the most important one. GCC 2.95 vs 3.0 vs 3.1 vs 3.1.1 vs 3.2 vs 3.4, all have different C++ ABIs. KDE apps compiled with 3.2 won't work on 3.4 distributions unless the user recompiles QT and other libraries.

The C++ ABI was *already* standardized. But it's so complex that nobody has managed to do it correctly. A while ago, both GCC and Intel found bugs in their compiler so they 'fixed' them and now produce a different ABI. How long before they find more bugs and break ABI yet again?

Hm seems like you have no idea about programing. C is low level langauge, it has those fancy *(c++) = *(--b) operators for a good reason (move-post increment instructions), so it is just natural that something low level as D-BUS is implemented in C. Whats more, writing bindings to C++ is hard...

It seems like you have no idea about programming. Making such stupid general statements about C++ libraries and bindings. It is perfectly feasible to implement libraries elegantly in C++ and write beautiful bindings to them.

When you want to write bindings to C++ libraries it's always neccesary to make a intermediate library in C to convert it to a plain API (CLX for Example, need Pascal bindings for QT), and this way isn't beautiful for me, although QT library in elegantly implemented in C++.

The problem with bindings is the ABI not C++ itself. Name mangling, virtual (method) table structure, memory alignment and calling conventions are the main issues that must be solved for a working binding. And who known better about these ABI things than the compiler for the API itself. So instead of finding out how to map the C++ ABI to Delphi' ABI and invest additional time when a new gcc is released (gcc had a really inconsitent ABI in the past), you "simply" write a C wrapper shared object in C++ and recompile this when gcc has changed.

It is possible to map the C++ ABI of gcc 2.95 to Delphi and it is possible to map the ABI of gcc 3.1 to Delphi ABI.
Name mangling can be resolved by Delphi's shared object import concept "function name(parameter): RetType; cdecl; external soName name 'symbol';" plus the c++filt utility.
VMT mapping works as long as the base class has a virtual method declared before a field, so the C++'s VT pointer is at offset 0. (QObject works perfectly). Otherwise you must use the obsolute "object" keyword (from TurboPascal days). It is the corresponding type for C++'s "class" keyword, but it is obsolute and said to have many bugs (I never found one).
For gcc 2.95 you must declare two dummy virtual methods to move the VMT offset of the first real virtual method 8 Bytes down.
For gcc 3.x the dummy method is not necessary (and would lead to wrong calls)
Memory alignment is no problem at all. With Delphi you can adjust it {$ALIGN 4}
And the calling convention is furtunatelly the "cdecl" one.

But even if you implement all this (it works, I have tested it last year with QObject and QWidget) two issues remain:
1. What is with inlined methods/functions, they are not exported by the shared object. You must find them and reimplement them in Delphi by hand. And C++ programmers tend to use many inline function (at least Qt has lots of them)
2. What is with templates? Templates are always inlined. They are not possible in Delphi except you write all template specializations by hand. Qt does not have that many (what about Qt4 ?) but eight or more are even too many to keep in sync with newer Qt versions.

So you see it is possible with limitations. The perfect solution would be a very small C wrapper (templates?, inline functions) and a native ABI map. But when you already have a C wrapper why not add all things to the wrapper and simply use a C interface from the binding language to the C++ code.

If there would be a common ABI all these issues would not exist. .NET for example has such a common ABI. The intermmediat language is designed to support more than one programming language. That's the reason why beside C# there are also VB#, Delphi.NET, ...

I wish gcc would export an additional "common ABI" for classes and templates like joliet is for iso9660. It is additional but if you cannot read it you can use the "old" one (ok the comparision is not good). Another example is COM under Windows. You can use it in C++, VB, Delphi and even in all .NET languages. And if that "common ABI" would be controllable by a class modifier that would be really great. For example: Q_EXPORT __commonabi class MyClass {} In this case gcc would create a function pointer table for all non-private methods.

And as fields should not be accessed directly all could be handled through these function pointer tables. And you would have an included RTTI for each public and protected method. Even bindings could be generated without the source code.

You have some interesting ideas here, but it is all very compiler specific and so a practical binding could never be implemented this way. Also how do override C++ virtual methods in a Pascal class using this sort of technique? To me it looks like it only solves the problem of calling C++ methods from Pascal and not callbacks for virtual methods or slot invocations going the other way.

But then I see you're working on Qt#/Bugtussle, and I've been fishing around looking at those docs - interesting. I hadn't heard of it until Adam Treat mentioned it in his blog a few weeks ago. I hope by KDE 3.4 at least one of the three(!) C# bindings projects succeeds in wrapping the KDE api. There will be a lot more people interested in a C# binding than Pascal I would have thought.

I haven't done anything on my Kimono C# project for a while, because I've been too busy with ruby. And I really ought to spend some time getting the KDE java bindings improved a bit - so I'm not sure if I'll have come up with anything worthwhile by KDE 3.4. I don't think multiple C# bindings implementations are a problem, but it might be a good idea to ensure they are source code compatible if that was possible. Then a C#/KDE app written with one variant would compile and run with the other two..

> I hope by KDE 3.4 at least one of the three(!) C# bindings projects succeeds in wrapping
> the KDE api. There will be a lot more people interested in a C# binding than Pascal I
> would have thought.

When Adam is back we start to mix Bugtussle with Binge. Bugtussle is good in reading the doxygen XML files and Binge is good in writing C# bindings.
But at the moment I'm writing a C++Parser in C# to remove doxygen dependencies. Doxygen is a documentation tool and as such it is not really a good base for writing bindings. And the lastest doxygen makes template generation impossible because the xml base class entities lost the template parameters.
QByteArray derives now from QMemArray instead of QMemArray.
And I'm not in the mood to rewrite the APILoader code every time doxygen changes.

NO! It's NOT! These are lies perpetuated by people with language agendas (e.g. GNOME trolls) Look at libfam and look at all manner of languages and environments using it even though it's implemented in C++.

Language agendas? If anything, people like you have language agendas and deserve to be called trolls. There are GTK/GNOME apps out there that are written in C++, or Python, or whatever. They don't say "C++ sucks", they provide bindings for many languages. On the other hand, people like you say "C sucks, I don't care what legitimate reason you have to use C, you are an idiot for using C".

While it is still better to write the library in C++ and provide some simple C wrapper if a binding is really needed. Just look at QtC, its not so hard and you only need to wrap up the public API.
Many languages don't need bindings for C++ as there is already some compiler technology to mix them. C++, objC, Java can be mixed to some extent with gcc for instance.

"Just look at QtC, its not so hard and you only need to wrap up the public API.
Many languages don't need bindings for C++ as there is already some compiler technology to mix them."

The QtC library has been retired and replaced by Smoke. It's not true that just because gcc supports java or Objective-C you don't need bindings for them.

"its not so hard and you only need to wrap up the public API"

Umm, I would like to say language bindings are easy, but they're not. Ashley Winter's Smoke library design is one of the most innovative things in KDE in my opinion. A long, long way ahead of what I managed with my first attempts at language bindings with QtC (as part of the effort to implement Objective-C bindings).

You could also use Fake Objects using C Structs or Pascal Records.
Looks a bit messier than true OO code but it works. The balance between OO and procedural code, while still having the power to export from a library. Messier than OO but cooler than OO :-)

I've attached a file which shows an example of a Pascal code with a few Fake Objects using plain records. Private data in the fake object is accessible if you want to shoot your foot, but is labelled very clearly using _private. Similar things have been done in the C language using _private or private_.

Call me messy but this was just a little experiment of mine. Note how I fake "self". Objects have a self available and in order to make "self" available using records/structs, you must pass a dummy Self parameter throughout some of the functions.

The example file attached shows how to use a Pointer to a record or a regular record without being a pointer. See FakeObject versus TRecord in the attached file. EXE demo is included on win32 - I'll make a linux elf some time later.

This example was done in delphi but should be easily compiled in FPC too. CompactUtils uses true objects, ignore that - the fakeobject examples are in the FakeObject directory.