Friday, 21 September 2007

What I hate in perl5 and Catalyst

Perl - references

Let's remove all simple data-structures like @lists and %hashes. When we think "list" let use list-refs, ref-hashes instead of hashes. Let's keep only scalars and references with implicit dereferencing, like in Python or Ruby. No wantarray context-dependent behaviour! No @{$foo} and \@foo and other nasty code! Perl will be clear and more funny!

current perl:
$foo = [ map { ... } @$bar ]

better perl:
$foo = map { } $bar

As I see folks have problems why we write:
%hash = (foo => 42);
$hash{foo} # where is hash sign, % ?

@list = qw/foo bar baz/;
$list[1] # where is list sign, @ ?

and there is no much difference between lists and refs, but differences between various forms of using refs are probably bigger than list<->ref:

$list[1][2] # wolf
$$list[1][2] # dog1
$list->[1][2] # dog2
$list->[1]->[2] # dog3

Sure, there is only one dog, welcome to TIMTOWDI world!

There are also some troubles with
$ref = \@list;
$ref = [@ref]
# maybe it is @list?
$ref = [ $some->method ]
# or maybe it is %hash?
$ref = { $some->method }

# could be better to make something like
$ref = $some->method->return_as_hashref
$ref = $some->method->return_as_arrayref

Maybe I should stop writing perl code because I think too much about all those things? ;)

Catalyst - index is different than other actions

What is a difference between:
Controller app::foo;

sub index : Private {
my ($self, $c, $param1) = @_;

sub show : Local {
my ($self, $c, $param1) = @_;


Index will not catch arguments, will not work with /foo/123, although /foo/show/123 will work that way. To fix index, we need to use LocalRegex

sub index : LocalRegex('^(.*)$') {
my ( $self, $c ) = @_;
my ($param1) = @{ $c->req->captures };

Tuesday, 4 September 2007

YAPC::Europe 2007 in Vienna

Larry Wall, Damian Conway, many great perl hackers, interesting events, all in one place in one time.

It was my first YAPC and also first YAPC talk (slides from Catalyst refactoring are with others from this yapc on slideshare - also check and Bartosz Jakubski's YAPC::EU 2007 photos.

However more interesting was to see in real life how this OS world works, met many interesting people from the perl community. There is probably nothing more interesting than long talks about POE, Catalyst and other kinda-like-app-servers or any other stuff during evenings near the Dunau Kanal and in other nice places in Vienna.

Huh, many words to say how great and cool was this YAPC!!!

PS: I will try to remember difference between Dbix and (Dbic or Dbix::Class) at least to avoid bot activation on #catalyst /and mst should also be happy ;)