Why we write elementary apps in Valaby David Gomes

If you follow elementary OS development, you may know that we do not write our applications on C or Python, but rather a language called Vala. While it is true that a more mainstream language would lower the barrier to entry for new first-party and third-party developers, Vala has proven to be a tremendously effective tool for our needs. Here's why:

Vala is an object-oriented programming language developed by the GNOME Project, which was first released in 2006. Syntax-wise, Vala looks and acts very similarly to Java or C#, which makes it easy for new contributors to leverage their knowledge and experience from other languages. Vala's clear syntax and tight coupling with the strongly-typed GObject system promotes highly readable, expressive, and maintainable code, while preventing entire classes of crashes and bugs.

Since Vala compiles to C (and then into binary), we gain access to a large number of bindings for libraries written in C. This is extremely important given the number of C libraries available for the Linux desktop. All of our desktop applications are written using the GTK+ toolkit, and many rely heavily on related GObject-based libraries, including Gee, WebKitGTK, VTE, and GStreamer. Bindings for dozens of popular GObject C libraries exist, and writing new ones is easy.

Before we adopted Vala, we wrote our desktop applications in Python. As both a language and a platform, Python made developing apps quick and easy. However, this ease of development came at a serious cost — performance, binding support, and maintainability became major pain points for us with Python. Worse, the slow and fragmented adoption of Python 3 over Python 2, particularly across Linux distributions, made packaging our apps and developer tools for different environments tedious and challenging. Vala's native binaries have proven to be a better fit for us.

Because Vala is developed by the same incredible folks who make GTK+, integration between Vala and GTK+ is tight. Here's an example from the official Vala source of GTK Samples

Extending GTK+ with Vala has also proven successful. In fact, we've crafted our own set of widgets that build on and complement what GTK+ provides by default. This super-set of GTK+, called Granite, is at the heart of nearly every elementary application, and Vala's excellent object-oriented inheritance system, among other sophistocated language features, have been key to our development.

Vala has excellent documentation, be it in the form of tutorials, code samples or a very easy-to-use API Reference. So if you’re interested in hacking on our projects (which we very much appreciate — we are always looking for new contributors!), or are planning to release fantastic third-party desktop applications for elementary OS, we can't recommend Vala enough. Dive in!

Published May 12th, 2014
Comments

42 Comments


fhjguieisie 2 months ago

[deleted]


fhjguieisie 2 months ago

[deleted]


Mike Lacey 2 months ago

Is there any documentation on building a Vala development environment?


Mike Lacey 2 months ago

Answer my own question…

Yes there is, tutorial documentation at:

http://elementaryos.org/docs/code


logos88 3 months ago

Do you consider Rust language to write apps in the long future? It looks like a very promising language :D


Shnatsel
Sergey Davidoff 2 months ago

Rust is more or less like C with memory safety, designed for the same use cases. While memory safety is a cool feat, Rust is a bit too low-level for us (AFAIK).


andrezlatin 3 months ago

The name you are using for your new OS is now used against us, to kill and terrorize people. I, and tens of thousands of users who read the news and know about the world we live in, can’t stand this anymore. It’s because your operating system is not for killing. I demand you now to call your creative team and get some name changes going. Please, do something! youtube.com/watch?v=vOGLesXQ4Tc


kasoki
Christopher Kaster 3 months ago

Isis is still the name of an Egyptian goddess though.


samuelcecilio
Samuel Cecílio 3 months ago

Don’t worry! Isis is not ISIS. And I suppose there is no terrorist in the Elementary OS dev team.


DanRabbit
Daniel Foré 3 months ago

We are aware of the Islamic State in Iraq and Syria (unfortunately abbreviated as ISIS). We are strongly considering an alternate code name for the next release of elementary OS. We’ll be keeping tabs on world events to see if more people associate the name with terrorism than with the mother goddess of Egypt.


brejoc
Jochen Breuer 3 months ago

Vala indeed looks not too bad. But what about UI developement? Is it possible to use Glade not only for pure GTK applications but also for granite based applications?


runej 3 months ago

...and if possible, then how to do it :)
I tried Glade yesterday, but coming from a VB environment found I might be missing some information about how it works in combination with Vala. I have the basic idea, but so fat only been able to write/compile in Terminal. If someone could make a short video tutorial…?


Phrodo_00 3 months ago

You just load the xml file with GtkBuilder, and then retrieve the references to the stuff you need.


runej 3 months ago

Is GTKbuilder something I have to install? Synaptics doesn’t know it…
And do I edit the code in GTKbuilder?
Thanks for your answer.


geocool
George Sofianos 3 months ago

Gtk.Builder is a class. You have to create a Builder object , load the glade file and then you ask from it the widget you need to handle.

Example:
var builder = new Gtk.Builder.fromfile(“myfile.glade”);
var label = builder.get
object(“label1”) as Gtk.Label;
label.set_text(“Changed label”);

Gtk.Builder class : http://references.valadoc.org/#!api=gtk+-3.0/Gtk.Builder


runej 3 months ago

Thanks a lot, that answered my question very welll.


brejoc
Jochen Breuer 3 months ago

Very nice. But how about Granite widgets? Would that also work with Glade?


geocool
George Sofianos 3 months ago

I’m not sure about it, but yesterday I found the Glade API Reference which had instruction of how to add custom widgets. Possibly elementary os team needs to write some code to support their widgets in glade.


runej 3 months ago

There is a blue print on it, however, as I understand it, it has low priority.
If someone files a bug report on it, I will support it on bountysource.
PS. I understand their priority, I just do not agree with it. Looking at Apple and Microsoft, it pays to give some extra attention to developers. So spent extra time on documentation and spent extra time on development tools and intergration, even it doesn’t pay back imidiately, the OS will greatly benefit from it in the long run..


DanRabbit
Daniel Foré 3 months ago

To be completely honest, I’m not sure it’s really reasonable to even build good pure GTK UIs in Glade. I wouldn’t recommend using it. I’ve only ever seen it cause problems. But that’s just my experience.

Load More Comments

Login to place a comment.

Just one second… Login in to comment, ask questions and more.
Cancel