Genie language

Now we're cooking with gas! I have been frequently browsing, investigating Python-lookalike languages. Well, it's the Python-like syntax that mostly interests me.

Today I discovered two amazing and very new languages, Delight and Genie. I'll report on Delight soon. Right now, here is info and initial impressions on Genie...

I had read briefly about Vala, a language that makes it easy to write GTK applications. It's syntax however follows the C-family (close to C#), which put me off. So, I never looked closely at it, but now I have done and it is really promising -- very efficient code generation, a true compiler, no runtime interpreter -- and just the plain old libc library. The compiler can also generate a C file.

Anyway, today I stumbled across this language called Genie, which is actually in the Vala package, and offers an alternative Python-like syntax. So, I downloaded Vala 0.5.1, compiled it, then created this "Hello world" application:


print "Hello world"

...that's it, just two lines.
Note: tabs are used for indentation, not spaces!
I then compiled like this:

# valac

Hey man, the executable is 2924 bytes (under 3KB)! Apart from libc, it also links in the 'libglib' and 'libgobject' libraries, which themselves only have 'libc' as a dependency.

What about a "Hello world" GTK GUI application? Yes, here it is:


/* GTK+ Genie Sample Code - compile with valac --pkg gtk+-2.0 */

Gtk.init (ref args)
var test = new TestWindow ()
test.show_all ()
Gtk.main ();

class TestWindow : Window

title = "Test Window"
default_height = 250
default_width = 250
window_position = WindowPosition.CENTER

destroy += Gtk.main_quit

var button = new Button.with_label ("Click Me")

button.clicked += def (btn)
title = "Hello World"
btn.label = "Hello World"

add (button)

...the first line means to use 4 spaces per tab.
Comment: that sure is simple code to create a GTK app.
I compiled it like this:

# valac --pkg gtk+-2.0

The app has a button, click it and "Hello world" appears. The size? -- just 5896 bytes (under 6KB). It requires all the usual GTK shared libs -- no binding libs needed!!!!

Yeah, I'm impressed. Read more:
Genie home:
Jamie McCracken blog:
Vala home:

Want to play? I have uploaded a PET package for Puppy4 here (1MB):

Posted on 22 Nov 2008, 18:25


Posted on 22 Nov 2008, 21:20 by BarryK
Genie and libc
I thought that probably the C libc functions are available, so tried this:


print "hello world"
stdout.printf("Hello again\n")

# valac -C

The generated C code:

#include "hello.h"
#include <stdio.h>

void _main (char** args, int args_length1) {
g_print ("hello world\n");
fprintf (stdout, "Hello again\n");

int main (int argc, char ** argv) {
g_type_init ();
_main (argv, argc);
return 0;

...yeah, works! Need to read the Vala docs to find out more about this.

Posted on 22 Nov 2008, 22:01 by BarryK
More Vala info
Online api docs:

Posted on 23 Nov 2008, 15:42 by lobster
genie 4 genie
Saving in windows format with auto line feed at end of file eventually allowed me to compile the second example and it was tiny.

The python syntax + the smallness and speed of C code - sound good to me. Keep us informed of any code you write

Posted on 24 Nov 2008, 5:41 by cb88
cooking with gas...
so.. that isn't an Americanism?

heh... and i though it was pretty much restricted to my area in the US

Posted on 2 Dec 2008, 8:01 by BarryK
Cooking with gas
Heh heh, I thought it was an Aussie saying!