Vala (programming language)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Vala
Paradigm(s) Multi-paradigm: imperative, structured, object-oriented
Appeared in 2006
Developer Jürg Billeter, Raffaele Sandrini
Stable release 0.15.1[1] (26 January 2012; 31 days ago (2012-01-26))
Typing discipline static, strong
Influenced by C, C++, C#, D, Java
OS cross-platform all supported by GLib
License LGPL 2.1+
Usual filename extensions .vala, .vapi
Website live.gnome.org/Vala

Vala is an object-oriented programming language with a self-hosting compiler that generates C code and uses the GObject system. Vala is syntactically similar to C# and includes useful language features like anonymous functions, signals, properties, generics, assisted memory management, exception handling, type inference, and foreach statements.[2] It is being developed by Jürg Billeter and Raffaele Sandrini. It aims to bring modern language features to C, with no added runtime needs and with little overhead, by targeting the GObject object system. Rather than being compiled directly to assembler or to another intermediate language, Vala is source-to-source compiled to C which is then compiled with a platform's standard C compiler, such as gcc.[3]

For memory management, the GObject system provides reference counting. In C a programmer must manually manage adding and removing references, but in Vala managing such reference counts is automated if a programmer uses the language's built-in reference types rather than plain pointers.

Using functionality from native code libraries requires writing vapi files, defining the library interfacing. Writing these interface definitions is well-documented for C libraries, especially when based on GObject, however C++ libraries are currently not yet supported. Vapi files are provided for a large portion of the GNOME platform, including GTK+.

Vala was conceived by Jürg Billeter and was implemented by him and Raffaele Sandrini, finishing a self-hosting compiler in May 2006.[4]

Contents

[edit] Code example

A simple "Hello, World!" program:

void main () {
  print ("Hello World\n");
}

A more complex version, showing some of Vala's object-oriented features:

class Sample : Object {
  void greeting () {
    stdout.printf ("Hello World\n");
  }
 
  static void main (string[] args) {
    var sample = new Sample ();
    sample.greeting();
  }
}

An example using GTK+ to create a GUI "Hello, World!" program:

using Gtk;
 
int main (string[] args) {
    Gtk.init (ref args);
 
    var window = new Window ();
    window.title = "Hello, World!";
    window.border_width = 10;
    window.window_position = WindowPosition.CENTER;
    window.set_default_size (350, 70);
    window.destroy.connect (Gtk.main_quit);
 
    var label = new Label ("Hello, World!");
 
    window.add (label);
    window.show_all();
 
    Gtk.main();
    return 0;
}

[edit] See also

  • Genie, a programming language for the Vala compiler with a syntax closer to Python
  • MonoDevelop, a programming IDE that runs on Linux, Windows and Mac OSX[5] with support for Vala
  • Shotwell, an image organiser written in Vala

[edit] References

  1. ^ "Vala Releases". 26 January 2012. http://live.gnome.org/Vala/Release. Retrieved 2 February 2012. 
  2. ^ Vala: high-level programming with less fat - Ars Technica. Retrieved Dec13, 2011 1:40PM EST
  3. ^ http://lwn.net/Articles/335966/
  4. ^ http://gnomejournal.org/article/80/writing-multimedia-applications-with-vala
  5. ^ multiple OS support

[edit] External links

Comparison with other languages
Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox
Print/export
Languages