Vala

GTK+ Extensions Made Easy Thanks to Vala

Writing proper GTK+ Widgets is difficult and time consuming. One of the big problems is the intricacies of the Gnome Object Model; the amount of boiler plate code that needs to be written to write a new class. Even writing a class that simply inherits from an existing class and adds some new state or behavior in tedious.

The problem is the syntax - the Gnome Object Model is a library for the C programming language that supplies a complete object model with inheritance, interfaces, reflection (for introspection) and so on. Where you might expect to see language features in an Object Orient language, you instead find naming conventions, macros and library function calls. Mastering the Gnome Object Model is no mean feat, and since C language bindings are preferred (possibly even expected, new Gnome libraries really need to be written in C. Or so that was the case until Vala came along.

Vala is a new language with syntax similar to C#. Vala does not compile directly to machine code, nor does it run on a virtual machine like .NET and Java. Rather, it translated into portable C code that is then compiled to machine code. The beauty of this is that the developer gets the benefit of writing in a higher level language than C which has appropriate language features while still being able to produce and distribute standard C language bindings for the Gnome Platform.

In this blog entry I demonstrate how to write a proper GTK+ Widget in Vala and compare it to what is required to write the same widget in C.

Subscribe to RSS - Vala