Brief rant about raku (what used be called Perl 6)

Brian Sturgill bsturgill at ataman.com
Wed Jan 5 14:02:45 MST 2022


I'll make the rant brief: Raku (the new name for Perl 6) is VERY fat.
No way in the world it's ready for production.

I ran these on my main Linux box running Ubuntu Mate 21.10.
(i5-8279U at 2.40GHz, 4 cores, 2 threads per core, mem 16M, fast SSD)

Below 'pwsh' is the name of the new cross-platform powershell (from
Microsoft).

RSS size of 'shells' or interactive languages sitting idle at prompt.

 Shell   RSS (M)
------- --------
raku         109
pwsh          90
ruby          22
python3        8
bash           6
ksh            4
perl5          4
dash           3
csh            1

RSS size of trivial Gtk program

 Language    RSS (M)
----------  --------
raku             279
pwsh             143
python3          45
go                   35

So, python needs 38 Megs to wrap gtk (it does this by directly querying
gobject info) and is thus smaller than the 53 megs pwsh uses [It double
wraps, first importing a csharp wrapper, then querying the csharp
reflection information.]

But HOW IN THE WORLD does one explain the 170 megs raku needs?

When I installed the Gnome::Gtk3 package into raku (using "zef")... it
took about 45 minutes!

One could argue the 90 megs of pwsh is large... but pwsh gives you
direct access to the entire .NET CLR core library AND the C# optimizing
compiler. A lot of the overhead is simply caching the symbols of that
wrapping. It does not particularly grow over time. You might wonder why
the compiler... well you can easily extend pwsh by dynamically compiling
C# and calling it from pwsh.

Here's an example:

```powershell
Add-Type -Assembly AtkSharp
Add-Type -Assembly CairoSharp
Add-Type -Assembly GdkSharp
Add-Type -Assembly GioSharp
Add-Type -Assembly GLibSharp
Add-Type -Assembly GtkSharp
Add-Type -Assembly PangoSharp

function hello($s, $a) {
Write-Host($s.Label)
 if ($s.Label -eq "Hello World") {
$s.Label = "Hello World Again"
} elseif ($s.Label -eq "Hello World Again") {
$s.Label = "Exit"
} else {
[Gtk.Application]::Quit()
}
}

[Gtk.Application]::Init()
$app = New-Object Gtk.Application("org.gtkapp.gtkapp",
[GLib.ApplicationFlags]::None)
$app.Register([Glib.Cancellable]::Current) | Out-Null

$btn = New-Object Gtk.Button("Hello World")

$btn.AddSignalHandler("clicked", [System.EventHandler]${function:hello})

$win = New-Object Gtk.Window("helloworld")

$win.AddSignalHandler("delete-event",
[Gtk.DeleteEventHandler]{[Gtk.Application]::Quit()},
[Gtk.DeleteEventArgs].asType())

$win.Add($btn)

$win.ShowAll()

[Gtk.Application]::Run()
```

I did not need to write any C# in this case, but did need to do coerce
types to get pwsh functions passed as callbacks, etc.

If it's not clear: I am calling the C# wrapper of Gtk, called GtkSharp
from pwsh. Until I wrote that pwsh had no knowledge of GtkSharp. No
special code had to be written to interface to it.

-- 

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.nclug.org/pipermail/nclug/attachments/20220105/429dadbd/attachment.htm>


More information about the NCLUG mailing list