perl - Moose vs. MooseX::Declare -


postlude

moosex::declare no longer recommended relies on devel::declare served purpose obsolete. @ point if wants mx::d should @ moops

original

assuming have decent knowledge of old-style perl oo, , assuming going write new code in flavor of moose (yes, understand there performance hit), wondering if deeper down either rabbit hole, going wish had chosen other path? so-monks enlighten me relative merits of moose vs. moosex::declare (or other?). how interchangeable are, 1 one class , other another, should choose switch.

(p.s. ok cw-ing question, think formed answer might able avoid subjectivity)

moosex::declare sugar-layer of syntax on moose. are, past parser, identical in produce. moosex::declare produces lot more of it, lot less writing.

speaking enjoys syntax of moosex::declare still prefers write of code in plain moose, tradeoffs on development & maintainability side.

the basic list of items of note when comparing them:

  • moosex::declare has much more concise syntax. things take several hundred lines in plain old perl objects (popo?), may take 50 lines in moose, may take 30 lines in moosex::declare. code moosex::declare me more readable , elegant well.

  • moosex::declare means have moosex::types , moosex::method::signatures free. leads elegant method foo(bar $bar, baz $baz) { ... } syntax caused people come perl after several years in ruby.

  • a downside moosex::declare of error messages much more cryptic moose. error typeconstraint validation failure may happen several layers deep in moosex::types::structured , getting there in code broke can difficult people new system. moose has problem too, lesser degree.

  • the places dragons hide in moosex::declare can subtly different hide in moose. moosex::declare puts in effort walk around known moose issues ( timing of with() example) introduces new places aware of. moosex::types example have wholly different set of problems moose's native stringy types[^1].

  • moosex::declare has yet performance hit. known moosex::declare developers , people are working on (for several values of working believe).

  • moosex::declare adds more dependencies moose. add 1 because people complain moose's dependency list around 20 modules. moosex::declare adds around 5 direct dependencies on top of that. total list according http://deps.cpantesters.org/ moose 27, moosex::declare 91.

if you're willing go moosex::declare, best part can swap between them @ per-class level. need not pick 1 on over in project. if class better in moose because of performance needs, or it's being maintained junior programmers, or being installed on more tightly controlled system. can that. if class can benefit clarity of moosex::declare syntax can too.

hope helps answer question.

[^1]: fewer, more. moose core developers still arguing one, , there no right answer.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -