On the long flight back from UDS-Lucid I read the Vala tutorial on my ebook, and did some of the exercises. I was curious about Vala because it combines the speed and memory efficiency of C in a sane C#-like language with proper memory management, exceptions, and without the silly “close to the metal” faff that is usually required in C.

And indeed I wasn’t disappointed. It’s not as convenient as Python, but really not far from it, and it’s faaaast!

Today I finally got back to this and wrote my first D-Bus example in vala which does a call to DeviceKit-disks:

using DBus;

int main(string[] args)
{
    Connection con = Bus.get(BusType.SYSTEM);

    dynamic DBus.Object dk = con.get_object(
            "org.freedesktop.DeviceKit.Disks",
	    "/org/freedesktop/DeviceKit/Disks", 
	    "org.freedesktop.DeviceKit.Disks");

    ObjectPath[] devs = dk.EnumerateDevices();
    foreach (ObjectPath o in devs)
	stdout.printf("%s\n", o);

    return 0;
}

Compile and run it with

valac --pkg dbus-glib-1 dbus-dk.vala && ./dbus-dk

and voila!