Vala is a new, high-level, object-oriented programming language that produces binaries for the native platforms. It aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C.
Vala uses valac a self-hosted compiler that generates C code and uses the GObject system. In this article, I will discuss how to install and use the Valac compiler in Ubuntu Linux.
Prerequisites
For installing required packages on your system you should have access to a user account with root user permissions.
How to install Valac in Ubuntu
Valac is available in the official Ubuntu repository, you can directly install it by using the apt command in your terminal. You can use one of the given methods to install Valac in Ubuntu.
Installing Valac from Ubuntu repository
Open your terminal and use the following command to install Valac on your system –
sudo apt install valac
press y and then enter when it asks for your confirmation.
Installing Valac using the official PPA repository
Another method to install Valac is to add its PPA repository and then install it by using the apt command. This provides you latest updated valac package.
Add the PPA using –
sudo add-apt-repository ppa:vala-team
Use the following command to install required dependencies –
sudo apt install software-properties-common
Next, run the update command to refresh the apt package repository –
sudo apt update
Finally, use the given command to install Valac from PPA –
sudo apt install valac
Press y and then enter when it asks for your confirmation.
You can verify the installation by checking the version of the installed package –
valac --verison
This should display –
Writing your first Vala program
The following code is the hello world program in Vala programming language –
void main() {
print( "Hello! World this is a Vala program!\n" );
}
Save this code with the .vala extension and use the following command to compile it –
valac hello.vala
Where hello.vala is the name of the file where I saved this program.
Now use the given command to run the program in Linux –
./hello
The following image shows the output of this program in Linux terminal –
To get more information you can read the official documentation of the Vala programming language.
Conclusion
So here you understand how to install valac compiler in Ubuntu Linux. Now if you have a query or feedback then write us in the comments below.