Learning AnyEvent

When people hear I learned POE much faster than AnyEvent, they're usually surprised. I don't know why, but POE always made a whole lot of sense to me than AnyEvent. I've used POE in several projects (some pretty big) and it was always easy to work with, always had every component I wanted (except the SSH I wanted, though that exists too now) and the community was totally supportive and helpful. This is not unlike AnyEvent, though. I just haven't used it much.

Recently I started using AnyEvent. Not because I don't like POE anymore but because I wanted to be familiar with both. I have to say I felt quite at home with AnyEvent and started to write more and more elaborate stuff with it. I'm also trying to find more stuff to do with it, though it feels suited for more hardcore people than I. I have no idea where to start if I wanted to write an AnyEvent SSH client based on Net::OpenSSH, for instance.

If you've ever used AnyEvent, I recommend getting familiar with POE. Rocco Caputo and the community have done amazing work on it.

If you've ever used POE, I recommend getting familiar with AnyEvent. Marc Lehmann and the community have done amazing work on it.


I prefer AnyEvent over POE, but should point out there isn't really an AnyEvent community. There's Marc Lehmann (schmorp AKA schmuck) who develops it and the users. POE might suck when it comes to the API, memory use, speed, etc., but it does have a true community behind it.

I also recommend Reflex, which is entirely object oriented throughout. It's closer to how I'd have written POE if I had Moose from the start.

It should work with AnyEvent, too, using either AnyEvent::Impl::POE or POE::Loop::AnyEvent.

Why stop at two event systems? Take a peek also at IO::Async:


It has a relatively small simple objecty API like AnyEvent, but a bit more structured in things like adding/removing real objects to its control, rather than you just letting object references fall out of scope when you're done with them.

Furthermore, you can generally mix just about all of them together, as CPAN contains bridge modules to run any of them atop any of the others. In fact I even had a go, last Christmas, at seeing how tall a stack I could build of even systems running on top of others:


I found AnyEvent too complex to use. I mean it shouldn't be harder, than using event library for C, even Marc's libev, but it is. So, why bother?

I find POE much more of an abstracted system. AnyEvent OTOH stays generally speaking closer to the metal than POE. I like that my knowledge of the system-level mechanisms are relevant there.

In POE you have to wrap your head around those concepts (such as wheels) before you can effectively use it, but they can be very helpful when building complex applications.

That said, I rather hate the 90's feel of it. I'm looking forward to trying out Reflex. It seems to provide one with the advantages of POE without the awkwardness.

I liked POE a lot when I first started using it, but I've had a lot of bad experiences with maintaining large software projects written in POE, where I haven't had the same problem with AnyEvent.

I should add though, that for any complicated system I always mix in Coro with AnyEvent.

I started with POE for the documentation and all the companions modules. I made big app very easily. I like it.

Then I tested AnyEvent. It is light, fast and now many modules exist on CPAN. Take a look to the principle of the CondVar: it is awesome ! I dream of all Net blocking modules using this working way. It would allow us to access them in a blocking AND non blocking fashion! THE dream :)

I am very happy to use AnyEvent now, even in an embedded environment, where Moose is not allowed...

Leave a comment

About Sawyer X

user-pic Gots to do the bloggingz