Jamie McCracken (jamiemcc) wrote,

Introducing Genie - the smart programming language



I have just created a nice cool new language which is now incorporated into latest Vala svn. This means that with the latest Vala compiler, you can now program in a language similar to Boo and Python for those that dont like Java/C# syntax.

The syntax of Genie is designed to be clean, clear and concise. In some ways its cleaner than Python and is certainly a lot more concise than C#/Java.

Genie of course has all the advantages of Vala and you can seamlessly use Vala code and bindings with it too just like a CLR.

And unlike most other modern languages, there is of course absolutely no slow, bloat laden VM either as it compiles into GObject C code.

Here's a GTK sample which uses the Vala GTK bindings to whet your appetite:


[indent=4]
/* GTK+ Genie Sample Code - compile with valac --pkg gtk+-2.0 genie-gtk.gs */
uses 
    Gtk
    
init 
    Gtk.init (ref args)
    var test = new TestWindow ()
    test.show_all ()
    Gtk.main ();


class TestWindow : Window

    init
        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)
        


To compile :
1) save above source to a file called genie-gtk.gs
2) valac --pkg gtk+-2.0 genie-gtk.gs

run the generated executable:
./genie-gtk


Some notes about the syntax:

1) It uses tab indentation for blocks (like python but only tabs and not spaces are allowed)
2) By default everything is public. To mark stuff as private either use underscore as first character in name of enitity or use the private keyword modifier
3) Genie supports everything vala supports including closures (see button.clicked above), properties, events (aka signals), delegates and other cool stuff

more to follow as I need time to document the language...

Update updated gtk sample above + added more documentation of language here
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 93 comments
Previous
← Ctrl← Alt
Next
Ctrl →Alt →
Previous
← Ctrl← Alt
Next
Ctrl →Alt →