With Raku being a general-purpose programming language (or, more precisely, a multi-paradigm language), you still think of it as more of a language to write programs that compute or do something with text or serve the web, but not interfaces. So I decided to answer a question if we can create full GUIs with Raku.
I started with Raku++ and ended up with a module called GUI::Wings that works on three platforms (macOS, Linux, Windows) and can be used with both Raku++ and Rakudo.
The Wings in the name is a word that reminds Windows, but is served by Camelia, the butterfly mascot of the Raku language.
The module is a proof of concept and allows you to build a GUI with three kinds of widgets: the window itself, buttons and labels. Raku’s coolness comes with the way the program reacts to the actions such as button clicks:
First, you create a button:
my $b = button 'Click me';
And then you enter a react loop to wait for the events to happen:
react {
whenever $b.clicks { ... }
}
To create the app, just create it and add its elements:
app 'Counter', {
window :title('Camelia counts'), :size(480, 220), {
my $l = label 'clicked 0 times', :font(28);
my $b = button 'Click me';
}
}
The module is shipped with two examples: a simple counter that shows how many times the button was clicked, and a standard desk calculator.
Below are the screenshots from the three different operating systems.
A fascinating fact is that you can run the programs with both Rakudo and Raku++ on each of the above-mentioned platforms.
On macOS, additionally, you can see how the window looks like if you run it with Gtk:
RAKUPP_MAIN_THREAD=1 WINGS_BACKEND=Gtk rakupp examples/calculator.raku

The module is available in the Raku ecosystem.


