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!
#1 by Vadim P. on 2009/11/28 - 03:38
Zitieren
I’ve been hooked on it for a while too. I think it’s quite nice.
#2 by anonim on 2009/11/28 - 11:32
Zitieren
why there’s so much redundancy on the dbus object declaration?
#3 by pitti on 2009/11/28 - 13:22
Zitieren
It’s not really. It’s bus name, object path, and interface name, which are different concepts. It’s just common practice to use a world-wide unique prefix in the style of reverse FQDNs.
http://dbus.freedesktop.org/doc/dbus-tutorial.html#concepts
#4 by arqim on 2009/11/28 - 18:39
Zitieren
vala is so great. This brings really a lot of fun and speed into programming.
And it’s fast and efficient.