#52WeeksOfCode Week 28 – Vala

Week: 28

Language: Vala

IDE(s): TextWrangler

History (official):

(From the Vala project home page)

“Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C..”

History (real):

Oh, there’s so much to unpack here.

new programming language” – okay, I’m with you so far.

modern programming language features” – I think I need some details on this one, bub.

GNOME developers” – Wait, I know this one! GNOME is a free, open source, cross-platform desktop environment. It’s mainly found on Linux systems, but you can also install it on Windows, Mac OS X and other UNIX variants.

The GNOME Project was started because the major desktop at the time, KDE (K Desktop Environment) used some proprietary code which made it problematic for certain open source projects. GNOME, on the other hand, is built on completely free code and all of the source code is readily available for download and hacking.

without imposing any additional runtime requirements”- A runtime system consists of any additional files required to run a program. Every piece of software has some kind of runtime requirements. In the case of Vala, this statement simply means that you don’t need to install anything extra to run applications written in Vala. (We’ll get to the reason why in a bit.)

without using a different ABI” – ABI is short for Application Binary Interface. An ABI, on a high level, is a set of rules for communication between different software modules. One use of an ABI is to allow programs to talk to the host operating system. The ABI specifies things like how to pass information from one program segment to another. Normally, a developer doesn’t have to worry about the ABI (it’s taken care of by his development system) except in certain cases when he’s writing code in different programming languages and he needs all of his programs to talk to each other. The ABI referred to in the official statement above is the GNOME ABI. (Like the runtime thing above, we’ll get to the why in a bit. Spoiler alert: it’s the same reason for both.)

To sum up, Vala is a good language for writing GNOME applications because you don’t need to install anything extra except a Vala compiler. Sounds good!

Just a minute. GNOME developers were writing software before Vala came along. Why do we need another programming language?

For the answer, we’ll have to send our imaginations back to the early ‘70s. The Summer of Love was still in recent memory, the conflict in Vietnam was winding down and the voting age was lowered from twenty-one to eighteen. (“Old enough to fight, old enough to vote”)

Almost unnoticed during all of this excitement, Bell Labs researcher Dennis Ritchie was creating a new general purpose programming language that he called C. This by itself wasn’t that exciting but C was used to write the first release of AT&T Unix.

I can sense I’m not exactly blowing your skirt up with this, but hear me out.

Prior to that time, computer operating systems (the software that runs the hardware) were written directly to the hardware using assembly language. An assembly language was very low-level code that produced software that would only run on a specific type of hardware. That meant that if you wanted to run Awesome OS (™) on a different type of computer, you had to completely rewrite the operating system. Needless to say, this slowed down innovation in the computer industry significantly.

Here’s my point.

C was the first high-level (ie. human-readable) programming language that could be used to write operating systems. The beauty of high-level languages is that as long as you have the original code, getting programs to run on different computer hardware is pretty easy.

Dennis RItchie, in short, was the father of the portable operating system.

The consequences of this were huge. Computers can’t run without an operating system and the difficulty of creating an operating system for new computer hardware was a serious limitation to computer hardware innovation. Ritchie’s work revolutionized the computer industry.

What does this have to do with Vala? True to its UNIX roots, GNOME was written in C. Now C is a solid reliable programming language (as evidenced by the fact that it’s still in use over four decades later). However, C doesn’t have the features of more modern languages and so for general purpose programming it imposes more and more limitations on the developer as the state of the art advances. They have to work harder just to stay in place.

Vala is based on a pretty clever idea. It has all of the snazzy bells and whistles you expect from a modern programming language so it’s easy for developers used to newer languages like C# to pick up.

But the Vala compiler converts Vala code to C code which is then compiled into just another GNOME application. That’s why you don’t need to install any extra software or libraries to run programs written with Vala.


Once you have the Vala compiler installed, all you really need to start writing code is a text editor. I installed Vala using MacPorts and I’m going to use TextWrangler to write my code.

A basic Hello World program in Vala looks like this (courtesy of the GNOME Vala tutorial):

int main () {
   print ("Hello World\n");
   return 0;


Compare this to the same program (courtesy of the Content Creation Wiki) written in C ( and Vala reveals its roots:

#include <stdio.h>
#include <stdlib.h>

 int main(void)
  printf("Hello, world\n");
  return EXIT_SUCCESS;

Now I just compile my code and run the program:

valac hello01.vala
Hello World

Pretty straightforward, but not very modern. Let’s jazz it up a bit using some modern paradigms (courtesy of Dream.In.Code):

using GLib; // not required
public class HelloObject : GLib.Object {
   public static int main(string[] args) {
       stdout.printf("Hello World!\n");
       return 0;

It still works:

valac hello02.vala
Hello World!

The Vala Project has created a programming language that both embraces modern development techniques and honors its roots.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s