Friday 4 December 2009

A special Date, a special someone.

perl -MDateTime -E 'our $first_kiss = DateTime->new( year => 2007, month => 3, day => 10 ); say $first_kiss->delta_days( DateTime->now )->delta_days'

1000



Talk about serendipity, finding out about this 3 days before the actual date!

Taking her to dinner now ;-)

Thursday 26 November 2009

Thanksgiving

Did you ever look over a module you use to see who wrote it? There are people behind every line of code you use, people who once had the same problem you had and fixed it for you before you even saw it coming.

I believe today is Thanksgiving Holiday in the US. We don't celebrate anything like it in Brazil - heck, if it weren't for television most people here wouldn't even know about it - but I thought this would be a good time to say "Thank You" to the Perl community and CPAN authors, for making this such a nice language to work with :-)

I pay my bills coding with Perl, loving every minute of it, and I'm sure it wouldn't be half as fun if it weren't for the nice people behind the communities and all the awesome modules I get to use and rely on. Sometimes - and I know I'm not the only one - I spend hours and hours just browsing through CPAN like a developer's Wikipedia. Peeking over at recently uploaded modules is aways fun too!

So, today I pay my respects to some (not all, as I'd be here all week, if not longer - and I need material for next year :-P) of the CPAN authors of modules I use(d) over the years, and thank them. I'll also rate their modules and send them a private email to show my appreciation, just in case they don't ever read this.
  • Thank you Adam Kennedy, for PPI, Module::Install, ORLite, Strawberry Perl, for authoring/maintaining over 200 modules, and for being such a nice and enthusiatic person overall;

  • Thank you Kartik Thakore, for taking upon yourself the weight of the SDL Perl project just a few months after even learning Perl (and doing a well job while at it);

  • Thank you Matt Trout, for local::lib, DBIx::Class, and for bringing new life to the Perl world via the Iron Man Challenge and the Enlightened Perl Organization;

  • Thank you Graham Barr, for Scalar::Util, List::Util, and all the Net::* modules;

  • Thank you Cory Watson, for Chart::Clicker. I found out about it a couple years ago in Perlmonks and was blown away. Keep it up!;

  • Thank you Chris Marshall, not only for PDL but also for co-maintaining the awesome Perl OpenGL project together with Bob "grafman" Free (Thanks to you too, Bob!);

  • Thank you Adriano Ferreira, for Carp::Always, and for being the Brazilian author with most modules in CPAN. You're an inspiration to us all (mesmo entocado aí nas Minas Gerais... vê se aparece!!! :P)

Dammit, I tried keeping this short, but here I was immerse in CPAN awesomeness again. So, if you ever put code out there, be it a whole module, a minor contribution to someone else's, or even a simple bug report, THANK YOU. Be sure you made at least one person's life easier.

Oh, I'll also take my time today to use the perlthanks tool and say thanks to all the nice people who help with perl itself. None of this would be here if not for you guys... Thanks!

Friday 16 October 2009

make a video for YAPC::Brasil 2009!

Hey everyone! A lot of time without blogging, been really busy with work and almost all of my free time has been dedicated to making YAPC::Brasil happen - spawning a big Perl conference is a lot of work!

In case you haven't already heard of it, from october the 30th to November 1st, we're working hard to put forth the greatest and largest Perl-only event in the entire Latin America, celebrate the Joy of Perl among ourselves, and tempt everyone else to join us in developing the programming language that has the happiest users! Humble goals, huh? :-)

We're still learning the ropes, so we refrained from making too much international buzz about it, or inviting foreigners to come to this year's edition. This way we can improve and mature our organization, and next year provide an event of international proportions - maybe even pay for travel and expenses of some keynotes (many thanks to all sponsors who are helping us trying to stay above the red line).

Even so, we could really use your international support!

Make a short video of just a few seconds stating your name (and cpan/irc id if you have them), location, and give us a shout! Here's a standard boilerplate example:

"Hi there! This is $name, from $location, author of $foo. Welcome to YAPC::Brasil 2009, enjoy the conference!"

That alone would be amazing, but please keep in mind it doesn't have to be that short, and of course you're free to be as creative as you want in any words of motivation you guys may have for us. Let the Brazilian Perl community see for themselves that we're just part of a whole, and that Perl is used and widely supported all over the World! Hopefully we'll be able to put up a 5-10 minute long compilation to show in the conference opening ceremony.

Oh! Almost forgot! Send the video to garu at yapcbrasil dot org dot br - thanks :-)

Become a part of the YAPC::Brasil today! And maybe in the following years we'll be fortunate enough to enjoy your physical presence there as well :-)

Thanks edenc for giving this amazing video shouting idea for the event, and perigrin for reminding me to blog about it :D

And many many thanks to you, for taking the time to record and send that video to us!

Sunday 27 September 2009

Geeks love Perl!

Of course, you most likely already knew about this, seeing Perl featured in not one, but two episodes of popular tv show Chuck, and knowing it is the programming language with the happiest users.

But now John Dalton, LibraryThing's systems administrator, used LibraryThing's tagmash feature to come up with some hard data evidence of the difference between geeks and nerds:



As you can see, Perl is not just the only programming language mentioned, it is also looking as popular as Linux itself!

What are you waiting for? Join the revolution! Learn Perl now and see for yourself why we all like it so much :-)

Wednesday 2 September 2009

Padre 0.45 "stable" released!

It is again with enormous pleasure that I announce Padre, the Perl IDE, on it's 0.45 release. We are trying to mark some special releases as "stable", somewhat sync'd to rakudo (for our "six" win32 release that bundles Padre with Perl 6), so downstream packagers can do their thing without pulling their hair out for us issuing so many releases (last month, on Padre's birthday, we had 3 releases on a 10-day span). As a result, this release has only bugfixes and translation updates - both more than enough reason for an upgrade :-)

Also, this has some sentimental value for me as it is my last release of Padre. We have a very nice rotation scheme going on and Ryan52 volunteered for this month, so I gladly handed off the baton - it's been great, but I must confess I do need some vacation from the responsibility!

Many many thanks to all of you for making Padre such a great IDE for Perl, be it developing or just using it. Also, a big cheer to all translators who's time has been put to Padre - your help is very much appreciated!

Hey, maybe now I'll actually have time to blog about something other than Padre releases. Yay :-)

Tuesday 25 August 2009

Padre 0.44 released!

Hi everyone!

I'm happy to announce Padre, The Perl IDE, release 0.44. Since last week, azawawi++ kept his work frenzy going and added several neat features to Padre this week:

  • Help Search is now greatly enhanced, faster and even supporting help for Perl operators!

  • Padre now has an integrated "Quick Fix" feature for Perl code! Perl 5 quick fixes are still getting mature but we're all very excited on new ideas to help Modern Perl coding and beginners.

  • The Directory Browser has had several stability fixes as well, and is turning into a better feature each day.
Aside from the usual bugfixes from all Padre devs, other features worth noticing include the return of the F12 "save as" shortcut from szabgab++ and the new "Edit->Insert" menu option from teejay++ that let's you insert snippets and special values like today's date, file size, etc.

This release is also special because we're experimenting on a new "stable" release process. The 0.45 release is scheduled for the end of the week and will contain only bugfixes and translation improvements from 0.44. This will let us create "stable" packages for linux distros and different operating systems (such as win32), while still letting us work on bleeding-edge stuff (released about the same time, but as 0.46).

Many thanks to everyone that contributed to this release - be it developing Padre or just using it and giving us bug reports. Thanks everyone!

Padre 0.44 should arrive at your local CPAN mirror anytime now. Enjoy!


newcomer notice: in the programming community, specially in those that use IRC as a communication channel, it is common to use "++" at the end of someone's name/nickname to indicate praise for that person's work, that you acknowledge and are thankful for what they did in whatever topic you are writing about. It is a standard iteration to variables in several programming languages such as C and Perl, so we use it to say (what they did) increased their "magic value" - usually called "karma". So if you see yournick++ somewhere, be glad :)

Monday 17 August 2009

Padre 0.43 released!

Padre 0.43 was (finally) released! Only 16 days after our birthday release, we already have a lot of new features and several improvements, starting with a beautiful splash screen. Maybe we change the image on a somewhat regular basis like the Gimp project does, who knows? :-)

On the "new stuff that you're gonna love", we have:

  • "Quick menu access" option that let's you quickly browse through and select menu options without ever leaving the keyboard. Just press Ctrl-3 and start typing!
  • "Open Resource" option is also a great help to quickly find files inside any resources directory. Just type Ctrl-Shift-R and off you go.
  • Padre's search engine has been refactored and is dazzling fast! Also, if you select text (1 line or less) and press F3, it will do an active search for the selected entry without even invoking the Find dialog.
  • The directory browser now has an "open in file browser" option that opens the requested file/folder in your default file browser. Just right-click on any item on the directory tree to view the option (among others).
  • If you have Syntax Checking enabled, you can now use the new "Next Problem" option that points you to the line where the (next) detected problem is!
  • All PPI-based features now fully support perl 5.10.
  • The new Help Search option (F2) let's you browse through perl's documentation with ease.

We also had a lot of work on the "Important stuff that's not so visible" category, like reducing our dependencies, upgrading plugin support internals, testing and bug-fixing.

As usual, many many thanks to all Padre developers and translators for all their work (join us if you haven't already), and to all the users out there - the Padre project would not be half what it is without you!


Cheers, and until next time!

Friday 31 July 2009

On Padre's birthday, a gift to you (0.42 released!)


It is with enormous pleasure that I present Padre, the Perl IDE, release #42.

As you may have known from previous posts, this Monday was the 1st anniversary of Padre! Everybody got together over the weekend and several improvements and bugfixes were made. We even got a brand new Padre logo, the Blue Morpho Butterfly. Check it out above!

A few other highlights of the biggest Changelog we had since release 0.21 (weird, huh?!):

  • The Directory Browser is not only prettier, faster and more useful than ever (with a built in search engine and some DWIM behavior) but now also has a panel on the left side of Padre all for itself called "project tools". Alias++ && gabrielmad++.

  • Azawawi++ implemented smart highlighting, and now whenever you double click on a word will not only select it as usual but also show a green squiggle for each mathing word on that same document.

  • Azawawi also got to finish his work on initial support for Padre actions, which means an action can be re-used by anything running on Padre. This will most definitely have a major positive impact on future development of the project.

  • Bricas++ added a "right margin" option which will show a tiny vertical line at the specified column. This is a really cool visual aid if you don't want to get your strings beyond 78 characters or whatever standard you may have. Incidentally, he is also the maintainer of the PerlTidy plugin, which might help you even more on tidying you code.

  • Alias also added two new options: "Close This Project" to close all open files in the same project as the current file, and "Close Other Projects" to do the opposite. Something everybody used to editing several projects at the same time were really looking forward to.

As usual, many thanks are in order to everybody who got involved directly or indirectly in this release of Padre. And make sure to keep bug reports and wishlists coming!

Oh, one more thing: being a special "birthday edition", this release has a commemorative title on the main Padre window. Make sure you drop by #padre on irc.perl.org and help us go through enough changes/fixes so we can release 0.43 even better (and without that title :P)

Enjoy!

Thursday 23 July 2009

Padre 0.41 released!

Wow, not even a week passed and we already have a new version for you!

Aside from the usual bugfixes, Padre 0.41 has the following changes:

  • The deprecated and rarely visible "experimental mode" was completely removed;
  • Ahmad Zawawi++ is doing a huge revamp on Padre's internals (sorry, you'll have to wait for the birthday edition to get all the benefits), and thanks to him now run_command in a separate window works in win32 to support prompt('...') in Perl 6 and in Perl 5;
  • The long awaited find/replace inside selections feature is finally implemented for your refactoring pleasure
  • Also, Gabor Szabo++ created a brand new syntax highlighter configuration system. Plugins now can add more syntax highlighters and users can pick one per mime-type. Some plugins already support this (such as the Parrot and Perl 6 ones) so if you have them enabled you can already change your preferred highlighter (from Scintilla to STD.pm, for example);
  • Last but not least, Gabriel Vieira++ just kept going with his changes on the directory view. This time, not only does Padre got some really nice artwork for folders and files on the tree view, but also users are now able to drag and drop their files around.

With this brand new 0.41 release, we open the gates for this weekend's Padre birthday festival. I'll probably blog about it tomorrow. Until then, hack away :-)

Friday 17 July 2009

Padre 0.40 released!

It is with great pleasure that I announce Padre 0.40 is just fresh out of the oven!

This is a special release of Padre, The Perl IDE, on very different accounts:

  • Adam Kennedy++ ran his new toy (CPANDB with dependency Graphs) on Padre and was able to eliminate about 10 Padre dependencies, including some pretty hairy ones with lots of FAIL reports on CPAN Testers. This not only makes Padre lighter, but also greatly enhances chances of a successful install, and makes it really easier to package.

  • Our newest contributor, Gabriel Vieira++, committed several improvements to the Directory Browser (view -> directory tree), making it way faster and more usable than before.

The brand new Padre 0.40 should arrive at your nearest CPAN mirror in no time. Please report any problems or feature requests to our request tracker or on #padre at irc.perl.org. We're really excited and expecting to do a lot of work now that we're so close to Padre's "birthday release".

As usual, many thanks are also in order to all of Padre's unsung heroes, and just about everyone that helps us directly or indirectly turn it into one of the best IDEs for Perl development out there.


Have fun!

Sunday 12 July 2009

View your templates' structure as a graph

Some very nice visualization tools have emerged on CPAN lately, such as melo++'s MojoX::Routes::AsGraph and franckc++'s CatalystX::Dispatcher::AsGraph. Now, be it Catalyst, Mojolicious, Titanium, Jifty or whatever Perl web framework you use, you most likely use abw++'s amazing Template Toolkit for rendering your site. So I really missed something that would help visualize and untangle the usually complex template structure on a complex website. If you feel that way too, wait no more! :)

use Template::AsGraph

my $graph = Template::AsGraph->graph('mytemplate.tt2');


That's about it. You can also pass TT's configurations and even variables that might mangle with template flow:

Template::AsGraph->graph('template.tt2', \%config, \%vars);

This even lets you get the actual output of the template processing in case you want it as well (you do this with the OUTPUT setting on your config hash, btw).

The result? See for yourself:



Dev code's on github, and the first release should arrive at your local CPAN mirror anytime now.

Let me know what you think!

Monday 15 June 2009

Rate a Perl module today!

While CPAN is all in favor of TIMTOWTDI, when we search for a functionality we usually want the best option out there. Which is it? It's the one that best fits your needs, of course, and that's the whole beauty of it. But, when you're filled with doubt, where to look? Well, see what others think of the alternatives!

Enter CPANRatings

When coding non-Moose OO, I, for instance, really like Class::XSAccessor. So, it's about time I pay my respects to smueller++. The first thing I do is open CPANRatings website and look for it.


As important as this module is (at least for me), it has no ratings yet. So I click on "Rate this distribution" link as shown above. It points me to Ask++'s Bitcard login. To create your own login, all you need is an email account.


After clicking on "login", I get to type my email and chosen password. If this is your first Rating and you don't have a Bitcard account, just click on "register", as shown in the image below. It goes to a page very similar to the login one, with just the additional "Verify Password" field. It's quick and easy, and requires no personal data input. After successfully logging in, you can even set an option so it logs you in automatically in the future.


After the login, you get to rate the chosen distribution. You'll be presented with four fields: Documentation, Interface, Ease of Use, and Overall, and be allowed to place your vote in a scale 1 to 5, higher numbers being better. Since all fields are optional, you can leave any of them blank if you want. Finally, there is a "free-text" Review box where you can speak your mind freely about that distribution, its strengths and weaknesses, maybe even justify your choices in the fields above or talk about alternatives.


A few reminders are in order:
  • Be useful
  • Be polite
If you dislike a given distribution, don't write "this sucks". Give a constructive criticism, say why you don't like it, or even better, what could be done to improve it. And remember, you can always come back to your rating and edit it! (writing "this rocks" is also not very useful, so remember to explain your opinion be it good or bad - or just not write anything at all and stick to the ratings).

Also, refrain from rating your own distributions. Your module isn't rated? Ask a user to do it! If you wish to reply to a rating given to one of your modules, leave the ratings blank and just write the review.


Quick Access Through CPAN

What's that URL again? http://cpanratings.perl.org, but don't worry about it. Since most Perl developers live inside the CPAN search, there's a quick way to the ratings from there, too. After doing your search, just click on the module distribution link - the one with the version number, as shown below:


This can give a lot of information on a given distribution, including module lists, documentation, test results, bug reports, and... ratings! The image below shows me part of the result for Class::XSAccessor at the time of writing this:



As you can see, it has no reviews whatsoever. So let's write one! When clicking on "Rate this distribution", you are redirected to CPANRatings and can follow the steps just as before. Nice, huh?

Where to Start?

It doesn't matter, really. Find a module you use (or had to use) for any particular task, and take a couple of minutes to tell the world how you feel about it. This can be specially helpful not only to other users, but also to the developer himself/herself in order to get user feedback and further improve it.

As an example, a simple browse on Padre's Makefile.PL showed 22 modules (30%) without any rating, including Class::Adapter, Class::XSAccessor (and Class::XSAccessor::Array), IO (!), threads (!!!), and even Test::Most. Not **one** rating. Not even Padre has a rating yet!

It doesn't even have to be a "rateless" distribution either. Did you know that, by the time of this writing, PAR only has three ratings? Win32::API too! Even gaas++'s URI distribution, recently found to be one of the centers of the CPAN module cloud, has only two ratings!

When writing your usual "use MODULE" statement, think about it. Do you love it? Do you hate it? If someone were to ask about it, would you recommend it? Why?

Next time you see yourself lost amidst the CPAN jungle of alternatives, remember: we are all responsible.

So, what are you waiting for? Rate a module today!


Monday 1 June 2009

Fast, concise and reliable code? Try Perl!

Maybe you're new to programming. Maybe you just like learning new languages. But, from so many options, which one to choose?

Sure, you probably heard a lot about about Java. PHP too, specially if you're into web programming. If you're into open-source, you might have also heard about Python and, if you're a Object-Oriented junkie, Ruby. In all cases, you probably also heard about Perl.
Link
Perl.

Unfortunately, chances are you heard a lot of FUD about Perl. This topic itself has sprung a lot of comments and replies, so I'll not go there. For whatever purpose or language, you should never pay attention to FUD. So, don't. Instead, I'm gonna talk a little about what makes Perl the language of choice for so many people and companies.

Perl is fast!

I know, I know, benchmarking is evil (you can see a broader discussion about it here and here(slides+talk)). But you don't even have to benchmark your code to see how fast it runs. Perl is not purely interpreted and has several optimizations during compile time. If even after that your code is not fast enough for your purposes, you can use XS, SWIG or even Inline to create parts of code in C (or even Assembly, for that matter) where speed is critical.

Examples include Perl's OpenGL implementation, which has no statistical differences between the C implementation and even overcomes C in some operations (impressed? see the full story). I've also seen Lorn++'s LWP::Curl fetch web pages faster than the curl binary itself (I'll probably blog about this later on, but if you're interested, he could use your help!).

Not only that, but a Perl implementation also won the WideFinder contest, where people attempted to write a program that would benefit from paralelism present in modern CPUs with slow clock rate but many cores.

Perl lets you do more, with less code.

Perl's conciseness is so amazing that it's a popular game among programmers to try and write a program that solves a particular problem with less characters as possible (this is called golf, and you can see here how Perl stands out from the crowd in it). Not only that, but one-liners can be so powerful there are a lot of system administrators who use Perl as a command line tool instead of as a programmer would.

Sure, you can write a complete wiki in 5 lines of Perl. But, of course, it doesn't mean you should. Professional programs, written by professional Perl programmers, tend to be clear and scalable, yet still concise. If you're into metrics, you know this usually means faster development and fewer bugs in your code.

I recently came across the Computer Language Benchmarks Game and a nice graph of programs benchmarked against their implementations in several different languages. The X axis is slowness, while the Y axis is code size. So, an utopic optimal language would have all their programs on (0,0). Here's the result related to this post:


As you can see, Perl is not only a heavy player, it's one of your best choices when it comes to speed, size and dependability. Of course, you can help your language (whatever it is) improve it's average - even Perl! But I digress...


Perl has a powerful and modern object system.

It's called Moose. Perl 5 provides all the material to implement object orientation (OO) as you see fit. While writing standard Perl OO is easy if you actually understand OO, it's through Moose that you'll experience the actual ease of use and power of OO. Moose proudly stole all the nice features from other object systems present in different languages such as Java, Ruby, Smalltalk, Ocaml, Perl6, and implemented some sweetness of their own, such as Perl Roles.

-------------8<-------------
package Laptop;
use Moose;

extends 'Computer';

has 'weight' => (isa => 'Int', is => 'rw', required => 1);
-------------8<-------------

Beautiful, simple, elegant, powerful. Moose.


Perl has an amazing and active community.

The Perl community is HUGE and vibrant. We have several Perl Mongers groups spread around the globe, so you'll probably find one nearby (if not, you can always create one!). There are monthly social and technical meetings, workshops and major Perl conferences called YAPCs. But, if people are not really your thing, mind the code they produce: The Comprehensive Perl Archive Network (CPAN) has more than 16 thousand modules ready for you to use, earning the common saying that, with CPAN, "90% of your program - whatever it is - is already written". Play with the search utility and see for yourself! Not only that, by the time of this writing there was an average of around 200 new modules/versions uploaded every month!

But, most importantly:

Perl is fun!

When you first dip your toe into Perl, you might be a little scared of how can there be so many ways of doing the same thing (in the Perl world this is called TIMTOWTDI). Perl not only has a plural and flexible syntax, it lets you extend it, bend it, and modify it to suit your needs and style. With Perl, you are not tied to the way the language developer's wanted you to write your program. It lets you write your code, your way. So, letting your imagination flow, you can actually have fun while coding, be it writing clear, elegant and professional code during work (which can even be enforced with Perl::Critic and allies) or writing many other forms of art in your free time.

Perl is freedom - try it.

Monday 25 May 2009

Catalyst/Mojo Plugins for Padre now in 8 languages!

Catalyst is an amazing web framework, but requires a little learning effort before you get to do all the cool stuff. Mojo still needs some work (specially documentation-wise) but it's catching up as a solid simple-yet-powerful alternative for web development, specially if you're Perl begginer. As you may know, both of them have Padre plugins to further easen your developing process. To make it even easier, the new versions of Padre::Plugin::Mojolicious (0.02) and Padre::Plugin::Catalyst (0.03) now have localization support, so menu and messages can be displayed in your native tongue! Problem is, I don't know what your native tongue is ;)

Right now, they're already translated in these languages (besides original english, of course):
Is your native tongue not listed? Then please add support for it! You can find both plugins on Padre's svn repository. Let me know if you need any help creating a .po file from messages.pot. Also, since both Cat and Mojo plugins share almost the same messages, if you translate one of them, the other should be a quick and easy copy/paste process. Heck, I can even do it for you if you're too lazy ;)

Many thanks to all translators! Also, many thanks to jq, who did an excellent job adding translation support for plugins on Padre, and to szabgab++ for the impressive effort on enabling translation for all plugins under Padre's svn repo. Now we could really use your help translating not only these, but all of Padre's plugins!

Friday 15 May 2009

Test::More memory issues

You gotta love testing. And, writing Perl code/tests, you gotta love Test::More. It has a great API, it's cool, it's fast, it's stable, it's leaking memory... "Say what?!"

Yeah. I mean, it's not leaking leaking, just eating more memory at every test you run, be it is(), ok(), or whatever. See for yourself:
-------------8<-------------
use Test::More qw(no_plan);
while (1) {
is(1,1);
}
------------->8-------------
If you run this, you'll see memory consumption for the process going up at a very fast pace (use top or any other viewer), this is what it looks like on my system after 40K tests (a couple of seconds using the code above):

After a quick stop by #perl-qa, rjbs++ said it was a feature, not a bug. Apparently, Test::Builder (the backend for Test::More, Test::Simple and their siblings/derivatives) stores each test result, so by the time you're at 50_000 results, you'll have 50_000 hashes in memory, even if they are all just PASS tests.

This does explain the ever-increasing memory issue, but it's still a no go for me. Although 95% of Test::Builder users will never see this as a problem, I'm doing a lot of combinatorics tests, so a single .t of mine has to go through well over 500K tests, hitting a memory wall real hard.

Now, if you stumbled in that same problem, don't panic: there are at least two possible workarounds for it.
  1. Split you combinatorics tests into smaller test files, picking the variable with the most possible...erm... variations... and turn it into a different constant for each test file. If you picked a good one, the number of tests on each file will be exponetially decreased and the collected test data won't be such a memory burden.

  2. If you have huge/nested loops in your tests, you can take a reverse approach and instead of using "ok or not ok" functions, use "normal" (code) compares, triggering fail() if something bad happens. This way the testing framework will only store the history of failed tests, eating as little memory as possible.
Just a couple of hours before my "potential bug" report, Schwern++ replied confirming it was "working as designed", and was kind enough to patch those workaround tips in the "CAVEATS and NOTES" part of the documentation for Test::Builder (as it affects everything, not just Test::More). I really should thank Apocalypse++ for talking me into writing it :)

Of course, I still hope to see this problem go away in future releases, and (fortunately for me) so does Schwern. According to him, this was one of the design issues which brought Test::AtRuntime to a halt. As a result, his upcoming Test::Builder2 will have the ability to turn off history and the history sub-system will be a separate object. There also might be a happy medium where history contains just a count of each type of result - just as I hoped - which will allow most of Test::More's features based on knowing the results to continue to work while not eating up too much memory in a long-running test file.

Yay for testing, and for the Perl QA community!

Saturday 9 May 2009

Testing Differences in Templates

I've been doing some template refactoring now, and since I want to make sure the new templates render exactly the same as the old ones, I used Schwern++'s Test::More to compare their outputs for all combinations of input variables I had. Things were great for the first small-and-obvious changes, but at some point both outputs looked the same to me, and yet were still failing the test, meaning something was off. But what?

A quick CPAN search pointed me to Barrie Slaymaker++'s Test::Differences (now maintained by Ovid++). After that, all I had to do was replace my is() call with eq_or_diff() and voilá:

#   Failed test 'templates should produce the exact same output'
# at t/refactoring.t line 128.
# +---+------+---+----------+
# | Ln| Got | Ln| Expected |
# +---+------+---+----------+
# | 3 | | 3 | |
# | 4 | | 4 | |
# | 5 | | 5 | |
# * 6 |\t\n * 6 |\n |
# | 7 | | 7 | |
# | 8 | | 8 | |
# | 9 | | 9 | |
# +---+------+---+----------+
Ha! Much easier, much direct. After a simple extra tab removal, all tests were successful and I could move on. Yay!

Friday 1 May 2009

Padre + Mojolicious

You most likely already know about Padre, the Perl IDE (if you follow this blog you do!). It's quickly becoming a great environment for beginners to learn Perl, and is already proving itself useful to some seasoned developers as well.

Recently, I talked about my Catalyst Plugin for Padre. It's also turning into a hit (yay!) and will hopefully help a lot of people doing web development in Padre. But Catalyst, amazing as it is, can impose a somewhat high learning curve for beginners, specially those not very familiar with (the also great) Template Toolkit and DBIx::Class.

This is where Mojolicious enters the scene.

Mojolicious is a next generation MVC web framework focused on minimalism and simplicity. It comes with the Mojo backend, a "framework for web frameworks". Through constant development and the tireless efforts of sri++, vti++, charsbar++ and several others, Mojolicious offers state of the art technology to deliver an environment where it is simple enough for beginners to get started, and powerful enough to just keep you going all the way.

Mojolicious is not a replacement for Catalyst, or vice-versa. They are just different approaches to the same problem and, although separately, both teams work very closely with each other (in fact, sri was -the- founder of the Catalyst project, and marcus++ is a channel op at #mojo on irc.perl.org). You should simply pick the one that best suits your experience and needs. And now you can do it inside Padre, too!


Padre::Plugin::Mojolicious incorporates helpers for Mojolicious inside Padre. Its behaviour is pretty much like the Catalyst plugin, letting you create new Mojolicious web applications, start and stop the webserver, and review some of the documentation.

Enjoy! And let me know if you have any suggestions to further improve it :-)

Friday 24 April 2009

YAPC::SA 2009


Perl is a very popular language all around the world. But how come all the nice Perl conferences happen only in Europe or the US? YAPC::Europe, YAPC::NA, PPW, NPW, FPW, LPW, ... the only (minor) exceptions to this rule are YAPC::Asia and YAPC::Russia - even so, all in the northern hemisphere.

South America has an astounding number of Perl developers. Right now there are nine active Perl Mongers groups in Brazil only, not to mention Argentina, Venezuela and other countries. 2007's Perl Survey data shows our stats compared to the rest of the Perl community, corroborating with what Dave Cross already saw back in 2005. So, where are the Perl conferences down in SA?

To my knowledge, South American Perl hackers are not used to huge Perl conferences. Maybe it's not in our culture, as there are a lot of us who just don't participate in the community at all: some claim they are too busy with their lives/jobs to engage or even attend to a meeting or conference (specially one that's not sponsored by a big company), others say they just never heard of the community in the first place (!). Imho this isn't actually a Perl problem: I've seen similar complaints from people on a lot of different languages. It's hard enough to get people in Free Software conferences, imagine a Perl-only one.

So, moved by a "if you build it they'll come" spirit, some people (including myself) arranged for YAPC::SA 2009 to happen!

----------------
YAPC::SA 2009
24 ~ 27 june - Porto Alegre - RS - Brazil
----------------

The event will take place inside FISL - the International Free Software Forum - a major FLOSS event which this year will have the participation of FSF's Richard Stallman and The Pirate Bay's Peter Sunde, among several others.

We're still learning the ropes and have a long way to go before getting even close to the major Perl events mentioned above. But nevertheless we're planning a great Perl conference for you, including hackathons, lightning talks, mini-courses, and the distribution of gifts - not to mention daily social meetings after the event.

Everyone's invited!

Tuesday 14 April 2009

Padre + Catalyst

For a while now, I've been contributing (or at least trying) to Padre - The Perl IDE. Although it still lacks some nice IDE features, it's really amazing to see how much has already been done in so little time. In fact, Padre releases are almost weekly, with Changelogs filled with active development and bug tracking. Szabgab++ managed to create an active and exciting community around the project, and I'm really glad to be a part of it.

One of Padre's cool features is plugins. Jq++, Alias++ and everyone else did an amazing job with the plugin API, so it's getting easier and easier to extend Padre's functionality. In fact, there are already over 20 plugins available on CPAN and many more to come. Recently, I created one myself, hoping it would improve the Padre experience and help developers of web applications, specially beginners: Padre::Plugin::Catalyst.

Installing the plugin should be fairly simple on the cpan shell

cpan> install Padre::Plugin::Catalyst


Of course, it has both Padre and Catalyst::Devel as dependencies. After installation, fire up Padre and go to the Plugins->Plugin Manager menu option.

The Catalyst plugin should show up. Select it and click on the "Enable" button so its status turns green (enabled), as shown in the image above.

That's it! The plugin and all its features can be accessed through its own menu at Plugins->Catalyst:


Let's browse through some of the options:

New Catalyst Application



This option will create a new Catalyst application on the specified folder. You can mark the "short names" checkbox to use "M", "V" and "C" folder names instead of the recommended "Model", "View" and "Controller" names. After clicking on the "OK" button, the plugin will create a skeleton program for you and ask if you want to open the created "Root.pm" controller so you can start programming right away.

Create New -> Model


This option lets you create a new model for your application. Here, you can specify your Model's name, type, and any additional parameters needed. "Type" is a list with all helper models available on your system, for you to choose from. It defaults to mst++'s DBIC::Schema (if available), as it's considered the ORM technology of choice for Catalyst.

Create New -> View


Similarly, this option will let you create a new View component for your application. "Type" defaults to the highly popular Template Toolkit helper, whenever available.

Create New -> Controller


With this option, you are able to quickly create a skeleton for any controllers your application may have. The default "Type" is no type at all, but, if you do use Controller helpers, you can also specify any additional parameters for it.

Start/Stop Web Server


At any point, should you want to test-drive your web application, you can click on this option to call the yourapp_server.pl script (where "yourapp" is the name of your Catalyst application, of course), a stand-alone development web server. All the output produced by the server will be displayed right on Padre's Output window (very useful for debugging), and it will ask if you want to open your web browser to actually view your application running.

Catalyst Online References

This option has quick shortcuts to some handy developer's information links available on the Internet:


That's about it :)

Future plans include letting the developer choose its favorite types, script updating features, and much more. If you want to help, you can checkout the current code from Padre's svn repository, or give me some feedback on any bugs or feature requests via Padre's Tickets or CPAN's RT.

Let me know what you think!