mengu on web programming.

Vala Programming Language

Many of my followers know that I have been developing an IDE and as my development language I have chosen D for the IDE and I am using GTK as GUI library. (There is also a Qt binding for D named QtD, which is also good.) Some days ago I have stumbled upon a new programming language named [Vala](http://live.gnome.org/Vala). Actually it is not new as it has been in the scene since 2006. So why Vala exists? Why another programing language? > Many developers want to write GNOME applications and libraries in high-level programming languages but can't or don't want to use C# or Java for various reasons, > so they are stuck with C without syntax support for the GObject type system. > The Vala compiler allows developers to write complex object-oriented code rapidly while > maintaining a standard C API and ABI and keeping the memory requirements low. > C# and Java libraries can't be used the same way as native GObject libraries from C > and other languages and can't be accepted as part of the GNOME Platform. Managed > applications also suffer from usually higher memory requirements which is not > acceptable in some situations. > valac produces C source and header files from Vala source files as if you've written > your library or application directly in C. Using a Vala library from a C application > won't look different than using any other GObject-based library. There won't be a > vala runtime library and applications can distribute the generated C code with their > tarballs, so there are no additional run- or build-time dependencies for users. Vala makes developing GTK/Gnome applications ridiculously easy. Here you can see a simple hello world for Vala: int main(string[] args) { stdout.printf("Hello World\n"); return 0; } Save this example as helloworld.vala and after compiling it with "valac helloworld.vala", you can run the example "./helloworld". Of course you need [vala compiler installed on your system](http://live.gnome.org/Vala#Download) first. Here is a quick GTK application for Vala: using Gtk; int main(string[] args) { // initialize Gtk Gtk.init(ref args); // create window var window = new Window(WindowType.TOPLEVEL); // set window size window.set_size_request(300, 200); // add an alignment var alignment = new Alignment(0, 0, 0, 0); // create an exit button var exit_button = new Button.with_label("Quit!"); // add a signal to the button. exit_button.clicked.connect(exit_button_clicked); // add exit button to the alignment alignment.add(exit_button); // add alignment to the window window.add(alignment); // add destroy event to the window window.destroy.connect(Gtk.main_quit); // show all widgets window.show_all(); // run the app. Gtk.main(); return 0; } void exit_button_clicked(Button button) { stdout.printf("Clicked exit button, closing the app.\n"); Gtk.main_quit(); } You can compile the files as "valac helloworld.vala --pkg gtk+-2.0" and then run the program. This is the result: ![Vala GTK Sample](http://www.mengu.net/repo/vala-gtk-sample.png) If you are C# developer, you can read [Vala for C# developers](http://live.gnome.org/Vala/QuickIntroForCSharpProgrammers) and if you are a Java developer you can read [Vala for Java developers](http://live.gnome.org/Vala/ValaForJavaProgrammers). For a complete Vala tutorial you can visit [http://live.gnome.org/Vala/Tutorial](http://live.gnome.org/Vala/Tutorial). Also [sample codes](http://live.gnome.org/Vala#Sample_Code) are really helping much. Why I have told all these? Because for the desktop applications that target GTK/Gnome platform, I think Vala is simply the best choice. As it's the best choice, I will definitely go and use it for my future GTK/Gnome applications. So, start using Vala and spread the word.
Check my latest project compector.com where you can post references about your former employers and see what others have said about the future employers. Sign up now and post a reference and share it on twitter or facebook.

Comments

Bowkomor said on 28/06/2010 22:28 PM
I completely agree with your post. I used to be (professionally) a Java programmer. Although, as everybody knows Java shines on the server side, for desktop development it's a real pain in the youknowwhere. I'm helping a friend to "make the move" from Windooz to Ubuntu and he needed me to develop a replacement for an M$ Access application. I stumbled on Vala (and by doing so on your website ;-). I was immediately enthousiast.

Mengu Kagan said on 29/06/2010 00:51 AM
Hello Bowkomor, I'm glad this blog post helped you out as a starting point. C# is going to evolve on Linux but until then Vala is the way to go for GTK/Gnome desktop applications. I also recommend taking a look at [the D programming language](http://www.digitalmars.com/d/index.html) as you can use the GTK binding named GtkD.

Leave a Response

No HTML allowed. You can use markdown.
Name*:
E-Mail* (not published):
Web site:
Response: