5 ms·
There's a school of writing "modern" Perl, using source filters and object systems. Bare Perl is a mess but, in somewhat of a Lispy way, you can use Perl to re
by juan_juarez 14y ago
There's a school of writing "modern" Perl, using source filters and object systems. Bare Perl is a mess but, in somewhat of a Lispy way, you can use Perl to rewrite your Perl. If none of your functions have signatures and you're manually blessing objects, your codebase will quickly turn to shit. Using a standard bits (such as Moose) to give you a consistent object system and method call syntax changes things dramatically.
- knighthacker 14y ago+1 I definitely recommend reading "Modern Perl". It is a game changer. http://www.onyxneon.com/books/modern_perl/index.html http://www.onyxneon.com/books/modern_perl/index.html
- lazyjones 14y agoThis is a new fad and it undoubtedly leads to more maintainable code, but it still feels like a bad tradeoff to me: you get the verbosity of stricter languages without the benefit (compile-time errors) at worse performance than plain Perl. I'd rather write something new in Scala or Go nowdays than in strict "modern Perl" style / Moose (and I've used Perl almost exclusively for the past 13 years).
- singingfish 14y agoumm, verbosity? package Point; use Moose; # automatically turns on strict and warnings has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); sub clear { my $self = shift; $self->$_(0) for qw/x y/} 1;
- colomon 14y agoVerbosity. class Point { has Int $.x is rw; has Int $.y is rw; method clear() { $.x = 0; $.y = 0; } } :)
- dkoch 14y agoPerl 6 is / will be sweet :)
- colomon 14y agoPerl 6 is sweet, and will be sweeter when it has better performance. :)
- deleted 14y ago[deleted]
- singingfish 14y agoLooks like a noble attempt to remove perl5 and ruby pain in the arse points simultaneously. Wonder if it will ever come to anything ...?
- draegtun 14y agoPerl 5.18 may have the following: use mop; class Point { has $x = 0; has $y = 0; method clear { ($x, $y) = (0, 0) } } ref: https://github.com/stevan/p5-mop/blob/master/t/000-examples/001-basic-example.t https://github.com/stevan/p5-mop/blob/master/t/000-examples/...
- singingfish 14y agoSource filters? Hahahahaha. The only acceptable source filter to use is Smart::Comments - https://metacpan.org/module/Smart::Comments https://metacpan.org/module/Smart::Comments - and even then, if you fire up code using Smart::Comments in the interactive debugger it's going to be a pain in the arse. Moo/Moose (and Mo and Mouse if you must) are on the other hand game changers.