Vala is a relatively new 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]
[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
- ^ "Vala Releases". 5 December 2011. http://live.gnome.org/Vala/Release. Retrieved 19 December 2011.
- ^ Vala: high-level programming with less fat - Ars Technica. Retrieved Dec13, 2011 1:40PM EST
- ^ http://lwn.net/Articles/335966/
- ^ http://gnomejournal.org/article/80/writing-multimedia-applications-with-vala
- ^ multiple OS support
[edit] External links
- Comparison with other languages
|
|
|
| Community |
|
|
|
| People |
|
|
| Components |
|
|
| Applications |
|
|
| Technologies |
|
|
| Other topics |
|
|