Object::Simple - Simple class builder, Mojo::Base porting

Object::Simple is simple class builder, Mojo::Base porting. Mojo::Base is simple and useful, but This is a part of Mojolicious. I port it as single module.

Object::Simple

  package Point;
  use Object::Simple -base;

has x => 1;
has y => 1;

package main;

my $point = Point->new;
print $point->x;

1;

Generally speaking, You can write any program using single inheritance and delegation. If you want simple class builder, Object::Simple is good choice.

5 Comments

Your documentation mentions Moose, but apparently you haven't heard of Moo, which most people are using as a light-weight Moose.

Actually no, Mouse is not more Moose-compatible than Moo.

Moo is designed so that Moo and Moose objects can work together seamlessly in the same program. Mouse is not. E.g. Moose roles cannot be applied to Mouse classes and vice versa.

The idea is that you start with Moo, which is simple and cheap. (It also has very few dependencies!) And if you need more features, you switch to Moose where you need it. And switching is easy, because Moo is designed to be runtime-compatible with Moose – so you can use Moose only where you need it and leave the rest of your code in Moo.

Mouse has more Moose-like features than Moo, but it is much less compatible with Moose. If you try to mix Mouse and Moose in the same program, and then try to do any clever metaprogramming things, you will have problems. And because of this, if you want to switch from Mouse to Moose or Moose to Mouse, you have to switch everything at once.

Leave a comment

About Yuki Kimoto

user-pic I'm Perl Programmer. I LOVE Perl. I want to contribute Perl community and Perl users.