Perhaps a misleading title. Seeing as this is not a political blog but a Perl one, I’m going to talk about method chaining, not worker’s unions.
Method chaining is the practice of consecutively calling methods on the return of a previous method. This comes in primarily two flavors. The first isn’t as common in Perl, though it is used extensively in
Mojolicious, is when a method has nothing useful to return, it can return itself. This allows for say chaining setter methods
$self->set_foo("FOO")->set_bar("baz"), or chaining related test methods
my $t = Test::Mojo->new;
->text_like('#id' => qr/foo/);
While this is useful, it’s not my topic today. I’m going to talk about the more simple form, calling a method that returns an object, then calling a method on it, and so on.
Most of my recent blog posts about Mojolicious have revolved around its non-blocking capabilities.
That said, lately I have had excuses to show off Mojolicious and when I have done so, it has been some of the other cool features that have garnered the “Ooooh”s and “Aaaah”s from onlookers.
In this article I will show you some of those extras, like accessing your generated pages and even app itself direcly from the command line.
I will also show how testing can be easy, powerful, expressive and yet still readably beautiful.
While I know many of you have CPAN Day projects, some of you might still be searching. There is a very well known benchmark from TechEmpower which compares web frameworks. It gets plenty of press and generates much interest. Unfortunately, the Perl results look like this:
We all know the reputation that Perl has to the outside world, and sadly these results would tend to reinforce it. The person or persons who added these apps seems to have long since forgotten about them. At least the Mojolicious app was a port of one of the others and did not exemplify either the style or power of the framework. The others likely share those traits.
But all is not lost! TechEmpower has recently made it much easier to contribute, and I have fixed the deployment and toolchain problems. I have also updated the Mojolicious app. Would you like to improve the submission of your favorite framework or add your own? Read on!
Just a quick reminder that noted perl luminary brian d foy will be at Chicago Perl Mongers tonight. He will be running his Become a CPAN Author Workshop which is a great way to start contributing to this famous repository. So if you have wanted to start playing with CPAN or you just want to meet brian then come on over! It is free as in beer AND there will be free beer!
Hopefully by now you have seen that Mojolicious is a great way to build your
non-blocking web (or even non-web) application.
Mojolicious come with all kinds of non-blocking functionality out of the box.
For more about that see my blog series
on the topic.
This post is an aside to show you the cool things happening in Mojolicious lately
designed to make writing non-blocking apps easier.
Mojolicious is known for fast development and clean APIs.
Mojo was that child with lots of excitement and energy, doing new and cool things,
providing new and cool functionality, and yes, changing its mind on occasion.
But Mojo is growing up and settling down a little bit.
It recently went to its first conference and professional training.
And it’s starting a family too!
Mojo is starting to feel more grown up, and grown-ups have responsibilities.
To borrow one of Perl’s catch phrases, this more mature Mojo knows that it is not
good enough anymore to just make things possible, it’s time to make them easy.