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.