Vala (programming language)
Encyclopedia
Vala is a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 created with the goal of bringing modern language features to C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, with no added runtime
Runtime
In computer science, run time, run-time, runtime, or execution time is the time during which a program is running , in contrast to other phases of a program's lifecycle such as compile time, link time, load time, etc....

 needs and with little overhead, by targeting the GObject
GObject
The GLib Object System, or GObject, is a free software library providing a portable object system and transparent cross-language interoperability...

 object
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 system. It is being developed by Jürg Billeter and Raffaele Sandrini. The syntax borrows heavily from C#. Rather than being compiled directly to assembler or to another intermediate language
Intermediate language
In computer science, an intermediate language is the language of an abstract machine designed to aid in the analysis of computer programs. The term comes from their use in compilers, where a compiler first translates the source code of a program into a form more suitable for code-improving...

, Vala is source-to-source compiled
Source-to-source compiler
A source-to-source compiler is a type of compiler that takes a high level programming language as its input and outputs a high level language. For example, an automatic parallelizing compiler will frequently take in a high level language program as an input and then transform the code and annotate...

 to C which is then compiled with a platform's standard C compiler, such as gcc.

For memory management, the GObject system provides reference counting
Reference counting
In computer science, reference counting is a technique of storing the number of references, pointers, or handles to a resource such as an object, block of memory, disk space or other resource...

. 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
GNOME
GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. It is composed entirely of free and open source software...

 platform, including GTK+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

.

Vala was conceived by Jürg Billeter and was implemented by him and Raffaele Sandrini, finishing a self-hosting
Self-hosting
The term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger...

 compiler in May 2006.

Code example

A simple "Hello, World!
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

" program:


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


A more complex version, showing some of Vala's object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 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+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

 to create a GUI
Graphical user interface
In computing, a graphical user interface is a type of user interface that allows users to interact with electronic devices with images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances and...

 "Hello, World!
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

" 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;
}

See also

  • Genie
    Genie (programming language)
    Genie is a modern, general-purpose high-level programming language in active development since 2008. It was designed as an alternative, simpler and cleaner dialect for the Vala compiler, while preserving the same functionality of the Vala language. Genie uses the same compiler and libraries as...

    , a programming language for the Vala compiler with a syntax closer to Python
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

  • MonoDevelop
    MonoDevelop
    MonoDevelop is an open source integrated development environment for the Linux platform, Mac OS X, and Microsoft Windows, primarily targeted for the development of software that uses both the Mono and Microsoft .NET frameworks...

    , a GNOME programming IDE
    Integrated development environment
    An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...

     with support for Vala
  • Shotwell
    Shotwell (software)
    Shotwell is an image organizer designed to provide personal photo management for the GNOME desktop environment. It has replaced F-Spot as the standard image tool for several GNOME-based Linux distributions, including Fedora in version 13 and Ubuntu in its 10.10 Maverick Meerkat...

    , an image organiser written in Vala

External links

, on GNOME Live!

Comparison with other languages
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK