2

I have been a searching for alternative to Moose (Modern object-oriented Perl) Because Moose is slow I have seen several post relation to this issue, I not want that. Example from the same creator: https://www.youtube.com/watch?v=ugEry1UWg84&feature=youtu.be&t=260

So I found this alternative from the same creator of moose:

https://metacpan.org/pod/MOP#DESCRIPTION MOP - A Meta Object Protocol for Perl 5

This module implements a Meta Object Protocol for Perl 5 with minimal overhead and no non-core dependencies (eventually).

Work with UNIVERSAL::Object:

https://metacpan.org/pod/UNIVERSAL::Object

Is this a good choice and alternative to Moose, does someone test this software ?

Related post: https://www.perlmonks.org/?node_id=1220917

Thanks.

Note: I forget to mention I know about Moo, Mouse, etc, maybe exist something better ?

Imylor
  • 384
  • 1
  • 9
  • 1
    Moose is only really slow if you run a web application with CGI or if you run backend applications that get started all the time and only take seconds or less to complete. If you are building for the web and your application is persistent, the startup time is more or less irrelevant, and the development time benefit you gain by using Moose and its large ecosystem will outweigh whatever you perceive as slow. Also note that resources that said it was slow a few years ago are now out-dated. – simbabque Nov 19 '18 at 15:59

2 Answers2

8

MOP is very low level, Moxie is based on it; but it's still a proof of concept.

There are faster and lighter alternatives that have been tested in production: Moo and Mouse.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • 2
    p5-mop (https://metacpan.org/release/STEVAN/mop-0.03-TRIAL) is no longer being developed. MOP on the other hand is one of Moxie's key dependencies and is part of the same effort at a new thing – ysth Nov 19 '18 at 16:11
  • @ysth: Thanks for correction, fixed. – choroba Nov 19 '18 at 18:04
1

In which context do you use Moose and find it slow ? There is of course an overhead involved, but most of it happens at startup time (compilation) ; then, at runtime, most features are cheap (as long as you make your classes immutable), as explained in the documentation. Over the time Moose has become the de facto standard for object oriented programming and it has a very, very wide ecosystem (a search on MooseX on metacpan returns 820 results). Don't give up on it to early.

If you really need faster startup time (like in vanilla CGI environment for example), the most relevant alternative to Moose is Moo, Minimal Object Orientation. It is really light-weithg, has no XS dependency, while implementing a significant subset of Moose (also, its syntax is fully compatible with Moose so you upgrade to Moose anytime later if you need some piece of functionality that you find missing in Moo). It also has a rich ecosystem.

GMB
  • 216,147
  • 25
  • 84
  • 135