Tuesday, October 16th, 2007
IWL: A Perl widget library for the web
Viktor Kojouharov was sick of constantly having html code snippets inside his perl code. He was seeing too many projects where the code was a messy mixture of perl, html, and in some places, javascript. Since he is familiar with the Gtk+ toolkit he decided to make something similar targeted for the Web.
He ended up with IWL which is, in Viktors words:
basically a graphical toolkit, or widget library, much like Gtk+ or the ETK library for enlightenment. The main goal of this library is to create a full blown RIA, without the need to write html in your code. When I started working on it roughly a year and a half ago, there was nothing similar existed for Perl. By using the library where I work, it has so far mostly achieved its main objective (and has also proven to be an excellent subject for my diploma thesis :))
If you are a Perl developer who prefers writing apps in a toolkit style like below, then IWL may be fore you:
- use IWL;
- # create the main container, and a few widgets
- my $page = IWL::Page->new;
- my $frame = IWL::Frame->new;
- my $iconbox = IWL::Iconbox->new
- (width => '800px', height => '600px');
- my $button = IWL::Button->newFromStock
- ('IWL_STOCK_CANCEL');
- my %some_icon_info = ("foo.jpg" => 'foo', "bar.png" => 'bar');
- # Setting up the icons and adding them to the iconbox
- foreach (keys %some_icon_info) {
- my $icon = IWL::Iconbox::Icon->new;
- $icon->setImage($_);
- $icon->setText($some_icon_info{$_});
- $icon->setDimensions('64px', '64px');
- $icon->setSelected(1) if $_ == 'something';
- $iconbox->appendIcon($icon);
- }
- $page->appendMetaEquiv("Cache-control" => "no-cache");
- $frame->setLabel("Frame label");
- # Adding the children to their parents
- $frame->appendChild($iconbox);
- $frame->appendChild($button);
- $page->appendChild($frame);
- # Finally printing the page
- $page->print;





Great! Now a GUI designer could be written for such – it’s much more easier to do with a toolkit-style system than a plain HTML-templating based one.
If you look at the NetCraft stats published yesterday, you can see that IIS has a serious gain, and it would be hard to say .NET and its design tools aren’t to be taken into account:
http://news.netcraft.com/archives/2007/10/overalld.gif
So, toolkit-based approach and better IDEs would probably help out some developer communities.
(Personally I never liked .NET and I still prefer to write javascript rather than generate it – but trends are clear, some will need to move)
How about performance in larger websites? Will it scale?