Mojolicious Archives

Mojolicious: Do It For The Candy!

Most of my recent blog posts about Mojolicious have revolved around its non-blocking capabilities. I like to write about those because I think that it is those capabilities that can bring new eyes to Perl from other languages, much like Node.js brought eyes to server-side javascript (for the same reason). 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.

Non-blocking Mojolicious apps are even easier now!

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.

MojoConf 2014 Recap

Last week I had the joy to attend the first (and certainly not the last) MojoConf in Oslo Norway. It was an incredible experience! First and foremost I want to thank the Oslo Perl Mongers, the organisation and execution of the conference was first rate! I also want to thank Jan Henning Thorsen (batman), who graciously offered to host me. We had such productive conversations over evening congacs, both Perl and otherwise.

I will admit now, that had wondered if the community was large enough to support an international conference. I am quite happy to say that my fears were unfounded. We had attendees from all over the world, including the USA, France, Greece, Israel, the UK, Germany and others I’m forgetting I’m sure.

Glen Hinkle (tempire) gave a professional training, which was sold-out! When companies (and even a few individuals) are willing to pay real money for training, it goes a long way to prove that Mojolicious is the world-class framework that we know it is.

I was also impressed (as Glen was) at the talk given by Richard Elberger (riche) in which he touts his company and the success it is having replacing an enterprise Java application with a Mojolicious one. He shared the success of the transition, detailing how everyone from the developers to the development managers to the stakeholders have been impressed at the ease and power of Mojolicious and Perl! That is so encouraging to hear! He even had all those enterprisey words that I try my best to ignore at my $dayjob, but what a feeling to hear them spoken about Mojolicious!

From a personal standpoint, it was so much fun to meet all these wonderful people and programmers who I have interacted with online for so long. I love that I can hear Sebastian’s laugh when he writes “haha” on IRC now! I can see him and Marcus and Salve and Vincent and Nils and Jan Henning and Nicolas and Glen and Alexander and Dotan and Richard and all the others, as they were, sitting around their laptops at the hackathon, rather than just names scrolling along a chat window.

So now the conference is over, but my excitement for Mojolicious is still peaking. I got so many ideas and so much motivation last week that I’m almost not sure where to put my attention first. I can’t wait for the next MojoConf, it can’t come soon enough!

See the presentation videos on the MojoConf YouTube channel!

Writing Non-Blocking Applications with Mojolicious: Part 3

This the the third part in an on-going series about using Mojolicious to write non-blockging applications (with an eye towards the web, obviously). In part 1 I demonstrated the how it can improve the number of requests/clients served when the application uses high-latency backends (in that case a database). In part 2 I showed how each request can be sped up when that request needs multiple resources from a high-latency service (e.g. external web services).

In each, I showed a blocking example, then a non-blocking example. I then gave the usual warning that you had to use a Mojolicious server for the nonblocking version. While its true that you need a Mojolicious server to get the benefits of the nonblocking architecture, in this post I will show how with a little care in construction, you can build your application so that it will run correctly on any supported server and the nonblocking benefits will be evident where possible.

A lighter nopaste, using Mojolicious

This post announces the release of Mojolicious::Command::nopaste, a clone of App::Nopaste using the Mojolicious toolkit. I wrote it mostly as an example of using Mojolicious and its command system, but it has the side benefit of having a much lighter dependency chain than the venerable original (I already have the only required dependency on every box I use).

It also has a few bugfixes that the nopaste author either hasn’t tripped on, or had the time to fix (mostly in the Clipboard interaction on Linux) (sartak if you want to ping me I’d be happy to work with you on it). It has a slightly different list of services, including the very fun MathB.in but lacking Gist for now since the OAuth is something I don’t want to deal with yet. Any other services that people are interested in may be contributed via a PR or even a decent api spec.

Enjoy!

Writing Non-Blocking Applications with Mojolicious: Part 2

Last time, I showed you how to write non-blocking (web) applications using Mojolicious. In those examples, each action only had to perform one non-blocking action. In this article I’m going to take things a little further, introducing you to Mojo::IOLoop::Delay. I will use a delay object to perform multiple simultaneous non-blocking actions and wait until they complete before moving on, all without blocking the server for other requests.

Writing Non-Blocking Applications with Mojolicious: Part 1

One question I often hear is “Why should I chose Mojolicious versus one of the other major Perl web frameworks?” While I have many answers to that question, I personally believe the most important difference is that Mojolicious is designed to be non-blocking. Many of you will have heard of Node.js. The reason that Node is popular is that it is designed to be non-blocking. By writing your webapp in a non-blocking style using a non-blocking framework, you can often build a faster and smarter application, requiring fewer servers to handle the same amount of traffic. Although Perl has several web frameworks, only one was written with non-blocking design in mind: Mojolicious.

To demonstrate a non-blocking application, I am going to write a simple pastebin using Mojolcious and Mango, a non-blocking MongoDB library (from the same developers as Mojo).

Some code ports to Mojolicious, just for fun.

Today is a relatively minor holiday in the US, but I had work off all the same. I found myself experimenting (when I probably should have been working on my YAPC::Brazil talk :-/). Thanks to today’s PerlWeekly (you are a subscriber right??), I found out about an interesting post by Johnny Moreno which creates a tiny json service backend using Perl. Of course it uses CGI.pm to do so, which made me curious what a Mojolcious port would look like.

Anyone miss Mojolicious' memorize helper?

Mojolicious’s 4.0 release came with lots of shiny features but it also came with a lot of housecleaning. One of the old things swept away was the memorize helper, which would cache a part of a template and prevent its repeated evaluation. Do you miss it, as some users undoubtedly do, or else does this helper sound useful to you? Then read on, because its back and better than ever!

My "Mojolicious Introduction" now updated for 4.0

On Feb 28, 2013 I gave a talk to Chicago.pm about Mojolicious. I called it an introduction, but I really wanted to show some of the features that sets Mojolicious apart. Because of this, the talk moves very fast. It hits routing and responses quickly, hits testing often, on all the way to well-tested non-blocking websocket examples.

I promised to get my slides up afterwards but life (i.e. my doctoral thesis) got in the way. Now with the release of Mojolicious 4.0 I thought I would take the opportunity to right a wrong and get the slides up; so here they are: http://mojolicious-introduction.herokuapp.com/!

The talk is itself a Mojolicious app, the source of which is available from on GitHub. Not only are all the code snippets shown in the talk included, not only do they all run, but they are actually what is rendered by the talk (DRY++), so what you see is what you get! Please leave any feedback and ask any questions. I may not see the responses here, so feel free to ping me elsewhere if needed.

About Joel Berger

user-pic As I delve into the deeper Perl magic I like to share what I can.