Today I was searching for something and Google served me a page from perlmonks where a question about Tcl/Tk vs Perl/Tk was asked. The OP commented on the "horrible ugliness" of Tcl, and someone posted a Perl/Tk snippet as some kind of example of sensible Perl code:
#!/usr/bin/perl
use strict;
use Tk;
my $mw = MainWindow->new;
$mw->Button(-text => 'First Button',
-command => sub { print "You hit the First Button.\n" }
)->pack;
$mw->Button(-text => 'Second Button',
-command => \&second_sub,
)->pack;
$mw->Button(-text => 'QUIT',
-command => \&exit,
)->pack;
MainLoop;
sub second_sub
{
print "The Second Button invokes a Named Subroutine.\n";
return;
}
For comparison, here's the equivalent Tcl code:
pack [button .b1 -text "First Button" \
-command { puts "You hit the First Button" }]
pack [button .b2 -text "Second Button" -command secondProc]
pack [button .b3 -text "QUIT" -command exit]
proc secondProc {} {
puts "The Second Button invokes a Named Subroutine"
}
It is a strange thing that some people find the almost sublime clarity, conciseness, and (yes, I would say:) beauty of Tcl "horribly ugly" while accepting the labyrinthine and bizarre syntax of Perl as usable.