reback00 e47365ebd1 Initial commit | il y a 4 ans | |
---|---|---|
.. | ||
.gitignore | il y a 4 ans | |
README.md | il y a 4 ans | |
hello-oop.vala | il y a 4 ans | |
hello.vala | il y a 4 ans |
Wikipedia says:
Vala is an object-oriented programming language with a self-hosting compiler that generates C code and uses the GObject system. Vala is syntactically similar to C# and includes notable features such as anonymous functions, signals, properties, generics, assisted memory management, exception handling, type inference, and foreach statements.
To install:
# Debian:
sudo apt install valac
# Void Linux:
sudo xbps-install valac
# Arch Linux:
sudo pacman -S vala
More distros here.
The shortest example of a vala program I could find is:
void main () {
print ("Hello World\n");
}
A more complex version of this with object oriented features would be:
class Sample: Object {
void greeting () {
stdout.printf ("Hello World\n");
}
static void main (string[] args) {
var sample = new Sample ();
sample.greeting ();
}
}
Save it on a test.vala
file, then run valac test.vala
. This will give you a test
binary file. Execute it with ./test
to see it running:
$ valac test.vala
$ ./test
Hello World