Sign inSign up

100hellos/vala

By 100hellos

•Updated 4 months ago

"Hello World!" Written in vala

Image
0

3.6K

100hellos/vala repository overview

⁠Hello World! From vala.

Language page⁠ — context, influences, and learning notes on the 100hellos site.

Source on GitHub⁠ (100hellos/vala)

⁠Trying it

docker run --rm --platform="linux/amd64" 100hellos/vala:latest

⁠Modifying it

Read the repo README⁠, or fork the project⁠ and customize it.

For an interactive shell:

docker run --rm --platform="linux/amd64" --entrypoint="" -it 100hellos/vala:latest zsh

⁠Vala – Modern Programming with a GNOME Twist

Vala is a high-level programming language that brings modern language features to the GNOME ecosystem, compiling to fast native code via C. It offers a clean, C#-like syntax, GObject integration, and powerful features like signals, properties, and type inference—all while producing efficient binaries.

⁠What makes Vala special?

  • C#-inspired syntax: Enjoy modern, readable code with type inference, properties, and lambda expressions.
  • Compiles to C: Vala source is translated to C, then compiled—giving you native performance and easy integration with C libraries.
  • GObject support: First-class support for GNOME's object system, including signals and properties.
  • No runtime required: Produces standalone binaries with no VM or runtime dependency.
  • Easy C library usage: Use C libraries directly with minimal boilerplate.

⁠The "Hello World!" explanation

This directory's hello-world.vala demonstrates several Vala features:

// Step 1: The simplest Hello World in Vala
void main () {
    print ("Hello World!\n");
}

// Step 2: Using a class and properties
class Greeter : Object {
    public string message { get; set; }
    public Greeter (string msg) {
        this.message = msg;
    }
    public void greet () {
        print ("%s\n", message);
    }
}

// Step 3: Using signals (Vala feature)
signal void greeted (string who);

void main_with_features () {
    var greeter = new Greeter ("Hello World!");
    greeter.greeted.connect ((who) => {
        print ("Greeted: %s\n", who);
    });
    greeter.greet ();
    greeter.greeted ("World");
}

// Uncomment to run the feature-rich version
// main_with_features();
  • Step 1: The classic one-liner using print.
  • Step 2: Defines a Greeter class with a property and a constructor, showing OOP in Vala.
  • Step 3: Demonstrates Vala's unique signal feature, allowing event-driven programming.

⁠Fun Vala facts

  • Vala was created by Jürg Billeter in 2006 to make GNOME development more accessible.
  • Vala code is compiled to C, then to native code—so you get the best of both worlds: modern syntax and native speed.
  • Vala is used in GNOME projects like elementary OS's Pantheon desktop.
  • You can use almost any C library in Vala with minimal glue code.

⁠Explore Vala further

Vala is a great way to write modern, fast, and maintainable code for the Linux desktop and beyond!

Tag summary

Content type

Image

Digest

sha256:6449720e6…

Size

175.3 MB

Last updated

4 months ago

docker pull 100hellos/vala