domingo, 19 de septiembre de 2010

ESUG 2010: It's awesomeness all way down

ESUG 2010 was held at Barcelona (well, technically, Cornellà). For people that don't know what's ESUG, it's one of the most important smalltalk events worldwide.

A week full of talks, great fun, hours of hacking and chatting with other smalltalkers.

The weekend before the conference, citilab was open to all smalltalkers who wanted to participate in the SmalltalkCamp. Two days of coding and meeting with other smalltalkers. I started rereading the seaside book and got some help from Bernat. It was fun to see the creators of what I was trying to understand (seaside) walking and coding around. Another nice curiosity was when someone entered the SmalltalkCamp with an OOPSLA t-shirt. It was like: "wow, important people around!" :)

Monday, at 9:00 the conference started officially, but by then, I had already met some great smalltalkers. Here is the schedule of the whole esug.

90% of the talks where amazing, I mean, good contents, with an accurate dose of humour, and talks given by people with nice speech skills.

Xtreams (Martin Kobetic), Design decisions behing Patagonia(Hernán Wilkinson), All Esteban Lorenzano's talks (mars and reef), Helvetia (Lukas Renggli), Stephane Ducasse's talks, Richie and ..... too many good ones to remember the name of all.

Citilab made a great job organizing it all, and we, the local group had very little to do (thanks to volunteers too). Myself I just had to help some people with maps, subways and take some smalltalkers to 'visit' Barcelona. :)

I bought a special edition of the seaside book and got it signed by Ducasse and Renggli. WOW!

Well, it's been a short and late post, but I can't write a post with all cool things I learned there, so it's more a "I've survived" post than a "hey, look what they showed us".

Soon, citilab will make the recordings of ALL the talks available on the web. I think they'll be hosted in cincom's servers. I'll post about that when it effectively happens.

I met many people and had lots of fun talking not only about smalltak but technology in general, and life, universe and everything. Mostly argentinians but not only them. Gabriel, Gabriela, Hernán Wilkinson, Leandro, Richie, Javi, Nico, Ricardo, Esteban Lorenzano,... Great people.

martes, 7 de septiembre de 2010

Capture the flag with Moose

In today's post, I'll show some ways to get program options via flags (--flags) I discovered recently.

CPAN is crowded with Getopt::* modules, but I'm going to explore the Moose universe.


At $work, we often have write commandline apps that end with lots of parameters and flags, and 'shift @ARGV' is not an elegant nor flexible solution. I've been using GetOpt::Long for years, but now, using Moose, I discovered an extension Called MooseX::Getopt.


This Moose eXtension allows you to fill attributes of an object directly from commandline.

We just have to use MooseX::Getopt in our Class, and change the creation of the object from Foo->new to Foo->new_with_options.


Now, our program can get all Foo's attributes through the commandline. Note that if you try an invalid flag, it will output the accepted ones.

- But wait, I do not want to allow users initialize all attrs.

Ok, then we should hide the attr under a name beginning with underscore, and set the accessor to our desired name. MooseX::Getopt will understand you don't want it to be accessible through command line options.


The summum of DWIM is you can also exploit the same introspection capabilities to enable configuration files to setup the execution of the files. And it costs you just one line.
with 'MooseX::SimpleConfig';

The code above will activate an extra flag (--configfile) where you can indicate where to reach the configuration file.

There are more goodies you can add on top of these modules, but for now, I think it's enough for me. :)

From these findings, you can see, Moose is not only a great OOP platform for perl but a higher level base for perl hackers to put stuff on.

Thanks Perl community.

viernes, 3 de septiembre de 2010

Parallel::Iterator. Independent tasks are independent


Today's module is Andy Armstrong Parallel::Iterator. I discovered it through Dagolden's blog, and tried it by myself that same day.

The idea is simple. You may have many slow tasks to do that don't have dependencies between each other. A typical example is fetching for webs using lwp, but I can think of lots of processes doing similar things, for exmple, ssh-ing some command to many different servers.

So it's like an autothreading map. Well sort of.

As tasks are not guaranteed to end in order, and you probably want to know which source procuded each result, the function you'll apply to each element will have to take not one but two parameters, the first being just an index that you can throw away. At least it seems so. I'm not sure I understand it fully, but for the moment that's what I gathered.

The module provides two sets of functions, iterate, and iterate_as_(array|hash), iterate returning tuples ($index, $result), and the others returning the wanted structure.

But what puzzles me is that I cannot easily migrate a normal map to this parallel::iterator because functions sent to map have to accept an extra parameter (just to throw it away?). Two days ago I read another post related to it but it didn't comment anything about that 'strange' use of it.

So I hacked a higher order function that mimics map signature but uses parallel::iterator. I'm probably missing something because it's strange the author didn't provide something like that in the module. Anyway, here it is:

I'm using the iterate_as_array because I want to mimic map signature, so the array to iterate can't be lazy built. That's another feature of Parallel-Iterator : not only the evaluation of the method can be lazy but also the generation of the list.

Ideas? Suggestions? Insults? Go on and comment :)