Zydeco::Lite

Today I released Zydeco::Lite, a re-implementation of Zydeco but just using standard Perl syntax. So for example, class { ... } becomes class(sub { ...});.

This has the advantage of much faster compile time, similar run time speed, fewer dependencies, and compatibility with older versions of Perl before the keyword API was introduced. Of course, in some circumstances these aren't important concerns, so the nicer syntax of the full Zydeco will be preferred.

Zydeco and Zydeco::Lite are both based on MooX::Press which itself is based on Moo, Type::Tiny, and other modules. I've taken the synopsis example from the Zydeco documentation and rewritten it using the different layers of abstraction.

Zydeco

The shortest example.

Zydeco::Lite

Zydeco::Lite is pretty similar, but with a lot more explicit quoting, a few extra commas, etc. Method signatures are probably where the lack of the syntactic sugar shows the most. Of course, you can just avoid using signatures and manually deal with @_ but I've tried to keep the examples as equivalent as possible.

MooX::Press

Both Zydeco and Zydeco::Lite are just cool DSLs for building a hashref that can be passed to MooX::Press. Here's how you can use MooX::Press directly.

Moo + Type::Tiny

MooX::Press calls Moo under the hood to build the classes, manages a type library for you, etc. This example shows most of what's happening, though in fact MooX::Press does even more than this.

Benchmarking

The following timings are for my 3-year-old laptop to compile and run the code in the examples:

  • Zydeco: 0.84 seconds
  • Zydeco::Lite: 0.16 seconds
  • MooX::Press: 0.14 seconds
  • Moo + Type::Tiny: 0.10 seconds

Leave a comment

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.