Friday, September 9, 2022

Elementary OS – Why we write elementary apps in Vala

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.

Vala is an object-oriented programming language developed by the GNOME Foundation, 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.

A Simple GTK Application in Vala

A Simple GTK Application in Vala

Because Vala is developed by the same incredible folks who make GTK, integration between Vala and GTK is tight. 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 sophisticated 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!



from Hacker News https://ift.tt/KPxrY93

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.