Sunday, August 3, 2008

Don't Like Mono? Try Vala.

My recent post about Mono was sincere, and Boycott Novell has the story about Debian wrong, but Gnome actually is pushing an alternative. Before I introduce you to the programming language Vala, let me give you some background on programming for Gnome as I understand it (note that I am not a programmer and haven't done anything real since the mid-80s).

Gnome is based on C, which makes it much more difficult to write for than, say, KDE, which is an object-oriented, C++ language. Gnome tries to put some OO structures on top of C, but developers often claim that they don't help a lot. As a result, Gnome developers (especially new ones) like to use bindings for other languages like Python, Ruby, or C#. These have drawbacks that the languages and bindings have to be installed, raising the install size (see Debian's complaint about Mono bringing in 50MB just for Tomboy). Mono's JIT executables are almost as fast as binary executables, but not quite. Scripting languages, though, are notoriously slow. None of the languages are a perfect fit for the GObject system, either.

Enter Vala, which is a new language developed by Gnome specifically for developing Gnome apps. It has a syntax very similar to Java or C# (closer to C# from what I've read) and a precompiler which maps the Vala to C source and header files, which can be compiled into an executable. The code is probably not as efficient as that written by hand, but Gnome claims very similar performance. Of course the use of a high-level language means that programmers shooting themselves in the foot with C is more difficult. The downside is that Vala programs aren't cross-platform like the other high-level options, but cross-compiling for three or four platforms shouldn't be too difficult.

Vala should reach 1.0 at the end of September, but only supports GLib and GTK+ right now. The entire Gnome platform is expected to be supported Real Soon Now (TM). There's already language support for it in GEdit and bindings for Monodevelop.

I've been playing with the example code, and it seems straightforward and simple to make GUI apps (eggclock is to the left). The language is really new, so there aren't a lot of applications writeen using it, but a fork of Cheese is trying to rewrite the application using Vala. There are also various multimedia, benchmarking, and text editing apps.

Mono and C# have a lot of really cool applications right now: Tomboy, F-Spot, and Banshee. If these were forked and rewritten in the C#-like Vala, we could see greater performance and silence the anti-Mono crowd. Sounds like heaven, eh? OK, I can dream, can't I?

Oddly, I don't really get an NIH feeling about Vala at all. I wonder why that is.

Solognu has translated this post into Spanish.


  1. Chris LeesAugust 5, 2008 3:40 PM

    It sounds like a really good solution to two problems. Does it really work for complex coding?

  2. August 5, 2008 6:35 PM

    If I uderstand correctly (not being a coder, but trying to get a hold of Vala), you COULD write any difficult parts in C if you wanted to.

    I do believe that, since everything maps to C, it will handle difficult stuff, too, though. It will be easier when all of Gnome is mapped to it.

  3. August 6, 2008 2:35 AM

    As I understand it, Mono is a framework while Vala is a programming language. It's exciting nonetheless though.

  4. August 6, 2008 5:36 AM

    Yes, you're right. I didn't really harp on that point, though. C# is the most common language for Mono and the one that really makes it shine.

    In the post, I mostly compared Mono/C# to Gnome/Vala.

  5. August 10, 2008 2:59 AM

    in spanish

  6. August 10, 2008 9:59 AM

    Thanks solognu. I've put you in a trackback with a clickable link.

  7. September 23, 2008 11:39 PM

    Small nitpick, but since Vala compiles down to portable ANSI C and only depends on GLib/GObject, which runs on everything from i386 POSIX (*nix, BSD, &c) to ia64 Windows (not sure about Vista, but XP definitely) to Maemo/ARM--and everything in between--I think it is extremely portable.

  8. September 24, 2008 7:57 AM

    That's what I was trying to say in the last line when I compared cross-platform to cross-compile, though it probably didn't come across correctly since I'm not a programmer.

    I meant to say that the Mono executable can be run cross-platform JIT, while Vala programs have to be compiled for each platform.

    Sorry to be ignorant about the terms needed and thanks very much for setting me straight.

  9. September 24, 2008 6:26 PM

    No worries. I see what you were saying now. Vala binaries for every application would have to be produced for every intended distribution platform (or else users would have to compile their own), whereas with the CLI (Mono or Portable.NET) or Python or Ruby, you only need the virtual machine / interpreter to be ported and you get all the programs for free. I was confused because most often "cross-compiling" refers to building binaries for one platform from a different platform (e.g., building on a Linux toolchain but targeting Windows PE binaries). Nice blog, BTW. :)

  10. September 24, 2008 6:34 PM

    Ps. One other point: Vala now has VAPI files (basically wrappers for C libraries that let Vala use them inside Vala code) for almost all of GNOME: Check out the list here in their SVN tree ( and in their external bindings listing ( There are a few others than haven't made it to either place yet, but can be found on the mailing list.


Other I' Been to Ubuntu Stories